1. 31 8月, 2012 2 次提交
  2. 30 8月, 2012 2 次提交
    • P
      vcpupin: Fix returning of arrays from virDomainVcpuPinAdd · 077e7bf5
      Peter Krempa 提交于
      virDomainVcpuPinAdd does a realloc on vcpupin_list if the new vcpu pin
      definition doesn't fit into the array. The list is an array of pointers
      but the function definition didn't support returning the changed pointer
      to the caller if it was realloced. This caused segfaults if realloc
      would change the base pointer.
      077e7bf5
    • P
      qemu: Fix possible infinite loop and segfault on error path. · 40dfb525
      Peter Krempa 提交于
      virDomainVcpuPinDefCopy when the control flow reaches out of memory
      cleanup code, the flow would end in a infinite loop as the loop variable
      wasn't decremented.
      
      Also a dereference of NULL pointers was possible if allocation of the
      Vcpu pinning definiton structure failed.
      40dfb525
  3. 28 8月, 2012 1 次提交
  4. 27 8月, 2012 1 次提交
  5. 24 8月, 2012 4 次提交
    • E
      snapshot: rename an enum · 1385c9cd
      Eric Blake 提交于
      The name 'virDomainDiskSnapshot' didn't fit in with our normal
      conventions of using a prefix hinting that it is related to a
      virDomainSnapshotPtr.  Also, a future patch will reuse the
      enum for declaring where the VM memory is stored.
      
      * src/conf/snapshot_conf.h (virDomainDiskSnapshot): Rename...
      (virDomainSnapshotLocation): ...to this.
      (_virDomainSnapshotDiskDef): Update clients.
      * src/conf/domain_conf.h (_virDomainDiskDef): Likewise.
      * src/libvirt_private.syms (domain_conf.h): Likewise.
      * src/conf/domain_conf.c (virDomainDiskDefParseXML)
      (virDomainDiskDefFormat): Likewise.
      * src/conf/snapshot_conf.c: (virDomainSnapshotDiskDefParseXML)
      (virDomainSnapshotAlignDisks, virDomainSnapshotDefFormat):
      Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
      (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotCreateDiskActive, qemuDomainSnapshotCreateXML):
      Likewise.
      1385c9cd
    • E
      snapshot: split snapshot conf code into own file · 6478ec16
      Eric Blake 提交于
      This has several benefits:
      1. Future snapshot-related code has a definite place to go (and I
      _will_ be adding some)
      2. Snapshot errors now use the VIR_FROM_DOMAIN_SNAPSHOT error
      classification, which has been underutilized (previously only in
      libvirt.c)
      
      * src/conf/domain_conf.h, domain_conf.c: Split...
      * src/conf/snapshot_conf.h, snapshot_conf.c: ...into new files.
      * src/Makefile.am (DOMAIN_CONF_SOURCES): Build new files.
      * po/POTFILES.in: Mark new file for translation.
      * src/vbox/vbox_tmpl.c: Update caller.
      * src/esx/esx_driver.c: Likewise.
      * src/qemu/qemu_command.c: Likewise.
      * src/qemu/qemu_domain.h: Likewise.
      6478ec16
    • E
      snapshot: make virDomainSnapshotObjList opaque · 3211deba
      Eric Blake 提交于
      We were failing to react to allocation failure when initializing
      a snapshot object list.  Changing things to store a pointer
      instead of a complete object adds one more possible point of
      allocation failure, but at the same time, will make it easier to
      react to failure now, as well as making it easier for a future
      patch to split all virDomainSnapshotPtr handling into a separate
      file, as I continue to add even more snapshot code.
      
      Luckily, there was only one client outside of domain_conf.c that
      was actually peeking inside the object, and a new wrapper function
      was easy.
      
      * src/conf/domain_conf.h (_virDomainObj): Use a pointer.
      (virDomainSnapshotObjListInit): Rename.
      (virDomainSnapshotObjListFree, virDomainSnapshotForEach): New
      declarations.
      (_virDomainSnapshotObjList): Move definitions...
      * src/conf/domain_conf.c: ...here.
      (virDomainSnapshotObjListInit, virDomainSnapshotObjListDeinit):
      Rename...
      (virDomainSnapshotObjListNew, virDomainSnapshotObjListFree): ...to
      these.
      (virDomainSnapshotForEach): New function.
      (virDomainObjDispose, virDomainListPopulate): Adjust callers.
      * src/qemu/qemu_domain.c (qemuDomainSnapshotDiscard)
      (qemuDomainSnapshotDiscardAllMetadata): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationIsAllowed): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotLoad)
      (qemuDomainUndefineFlags, qemuDomainSnapshotCreateXML)
      (qemuDomainSnapshotListNames, qemuDomainSnapshotNum)
      (qemuDomainListAllSnapshots)
      (qemuDomainSnapshotListChildrenNames)
      (qemuDomainSnapshotNumChildren)
      (qemuDomainSnapshotListAllChildren)
      (qemuDomainSnapshotLookupByName, qemuDomainSnapshotGetParent)
      (qemuDomainSnapshotGetXMLDesc, qemuDomainSnapshotIsCurrent)
      (qemuDomainSnapshotHasMetadata, qemuDomainRevertToSnapshot)
      (qemuDomainSnapshotDelete): Likewise.
      * src/libvirt_private.syms (domain_conf.h): Export new function.
      3211deba
    • M
      conf: Don't always require security/@model · 0ee655f5
      Michal Privoznik 提交于
      Only parse model, if static labelling, or
      a base label is set, or doing active XML.
      0ee655f5
  6. 23 8月, 2012 1 次提交
  7. 22 8月, 2012 9 次提交
  8. 21 8月, 2012 3 次提交
    • M
      qemu: Unify port-wise SPICE and VNC behavior · a14b4aea
      Martin Kletzander 提交于
      Port allocations for SPICE and VNC behave almost the same (with
      default ports), but there is some mess in the code. This patch clears
      these inconsistencies and makes sure the same behavior will be used
      when ports for remote displays are changed.
      
      Changes:
       - hard-coded number 5900 removed (handled elsewhere like with VNC)
       - reservedVNCPorts renamed to reservedRemotePorts (it's not just for
         VNC anymore)
       - QEMU_VNC_PORT_{MIN,MAX} renamed to QEMU_REMOTE_PORT_{MIN,MAX}
       - port allocation unified for VNC and SPICE
      a14b4aea
    • M
      Multiple security drivers in XML data · e9377dda
      Marcelo Cerri 提交于
      This patch updates the domain and capability XML parser and formatter to
      support more than one "seclabel" element for each domain and device. The
      RNG schema and the tests related to this are also updated by this patch.
      Signed-off-by: NMarcelo Cerri <mhcerri@linux.vnet.ibm.com>
      e9377dda
    • M
      Internal refactory of data structures · 6c3cf57d
      Marcelo Cerri 提交于
      This patch updates the structures that store information about each
      domain and each hypervisor to support multiple security labels and
      drivers. It also updates all the remaining code to use the new fields.
      Signed-off-by: NMarcelo Cerri <mhcerri@linux.vnet.ibm.com>
      6c3cf57d
  9. 18 8月, 2012 4 次提交
  10. 16 8月, 2012 1 次提交
    • L
      conf: add <vlan> element to network and domain interface elements · 3f9274a5
      Laine Stump 提交于
      The following config elements now support a <vlan> subelements:
      
      within a domain: <interface>, and the <actual> subelement of <interface>
      within a network: the toplevel, as well as any <portgroup>
      
      Each vlan element must have one or more <tag id='n'/> subelements.  If
      there is more than one tag, it is assumed that vlan trunking is being
      requested. If trunking is required with only a single tag, the
      attribute "trunk='yes'" should be added to the toplevel <vlan>
      element.
      
      Some examples:
      
        <interface type='hostdev'/>
          <vlan>
            <tag id='42'/>
          </vlan>
          <mac address='52:54:00:12:34:56'/>
          ...
        </interface>
      
        <network>
          <name>vlan-net</name>
          <vlan trunk='yes'>
            <tag id='30'/>
          </vlan>
          <virtualport type='openvswitch'/>
        </network>
      
        <interface type='network'/>
          <source network='vlan-net'/>
          ...
        </interface>
      
        <network>
          <name>trunk-vlan</name>
          <vlan>
            <tag id='42'/>
            <tag id='43'/>
          </vlan>
          ...
        </network>
      
        <network>
          <name>multi</name>
          ...
          <portgroup name='production'/>
            <vlan>
              <tag id='42'/>
            </vlan>
          </portgroup>
          <portgroup name='test'/>
            <vlan>
              <tag id='666'/>
            </vlan>
          </portgroup>
        </network>
      
        <interface type='network'/>
          <source network='multi' portgroup='test'/>
          ...
        </interface>
      
      IMPORTANT NOTE: As of this patch there is no backend support for the
      vlan element for *any* network device type. When support is added in
      later patches, it will only be for those select network types that
      support setting up a vlan on the host side, without the guest's
      involvement. (For example, it will be possible to configure a vlan for
      a guest connected to an openvswitch bridge, but it won't be possible
      to do that for one that is connected to a standard Linux host bridge.)
      3f9274a5
  11. 15 8月, 2012 10 次提交
    • L
      conf: log error when encountering multiple filterrefs in interface · 1f7a291c
      Laine Stump 提交于
      Each interface has a single pointer to a filterref object. That
      filterref can itself point to multiple other filterrefs, but at the
      toplevel there is only one.
      
      The parser had previously just silently overwritten earlier filterrefs
      when a new one was encountered, so the interface was left with
      whichever was the last filterref in the xml, ignoring all the
      others. This patch logs an error when it sees more than one filterref.
      1f7a291c
    • L
      network: add connections counter to networks · 300bcdb6
      Laine Stump 提交于
      Just as each physical device used by a network has a connections
      counter, now each network has a connections counter which is
      incremented once for each guest interface that connects using this
      network.
      
      The count is output in the live network XML, like this:
      
         <network connections='20'>
         ...
         </network>
      
      It is read-only, and for informational purposes only - it isn't used
      internally anywhere by libvirt.
      300bcdb6
    • L
      conf: output forward device connections count in network XML · 92a83040
      Laine Stump 提交于
      It may be useful for management applications to know which physical
      network devices are in use by guests. This information is already
      available in the network objects, but wasn't output in the XML. This
      patch outputs it when the INACTIVE flag isn't set (and if it's non-0).
      92a83040
    • L
      conf: rename interface "usageCount" to "connections" · 643feae7
      Laine Stump 提交于
      I want to include this count in the xml output of networks, but
      calling it "connections" in the XML sounds better than "usageCount", and it
      would be better if the name in the XML matched the variable name.
      
      In a few places, usageCount was being initialized to 0, but this is
      unnecessary, because VIR_ALLOC_N zero-fills everything anyway.
      643feae7
    • L
      conf: use a unique data type for PF array in virDomainNetDef · 95ae4e7f
      Laine Stump 提交于
      This array was originally defined using the existing
      virNetworkForwardIfDef, but that struct has a UsageCount field that
      isn't used in the case of PFs. This patch just copies that struct and
      removes UsageCount. It ends up being a struct with a single field, but
      I left it as a struct in case we need to add other fields to it in the
      future.
      95ae4e7f
    • L
      conf: support partially-specified <virtualport> in parser and formatter · 4af3cbaf
      Laine Stump 提交于
      Until now, all attributes in a <virtualport> parameter list that were
      acceptable for a particular type, were also required. There were no
      optional attributes.
      
      One of the aims of supporting <virtualport> in libvirt's virtual
      networks and portgroups is to allow specifying the group-wide
      parameters in the network's virtualport, and merge that with the
      interface's virtualport, which will have the instance-specific info
      (i.e. the interfaceid or instanceid).
      
      Additionally, the guest's interface XML shouldn't need to know what
      type of network connection will be used prior to runtime - it could be
      openvswitch, 802.1Qbh, 802.1Qbg, or none of the above - but should
      still be able to specify instance-specific info just in case it turns
      out to be applicable.
      
      Finally, up to now, the parser for virtualport has always generated a
      random instanceid/interfaceid when appropriate, making it impossible
      to leave it blank (which is what's required for virtualports within a
      network/portprofile definition).
      
      This patch modifies the parser and formatter of the <virtualport>
      element in the following ways:
      
      * because most of the attributes in a virNetDevVPortProfile are fixed
        size binary data with no reserved values, there is no way to embed a
        "this value wasn't specified" sentinel into the existing data. To
        solve this problem, the new *_specified fields in the
        virNetDevVPortProfile object that were added in a previous patch of
        this series are now set when the corresponding attribute is present
        during the parse.
      
      * allow parsing/formatting a <virtualport> that has no type set. In
        this case, all fields are settable, but all are also optional.
      
      * add a GENERATE_MISSING_DEFAULTS flag to the parser - if this flag is
        set and an instanceid/interfaceid is expected but not provided, a
        random one will be generated. This was previously the default
        behavior, but is now done only for virtualports inside an
        <interface> definition, not for those in <network> or <portgroup>.
      
      * add a REQUIRE_ALL_ATTRIBUTES flag to the parser - if this flag is
        set the parser will call the new
        virNetDevVPortProfileCheckComplete() functions at the end of the
        parser to check for any missing attributes (based on type), and
        return failure if anything is missing. This used to be default
        behavior. Now it is only used for the virtualport defined inside an
        interface's <actual> element (by the time you've figured out the
        contents of <actual>, you should have all the necessary data to fill
        in the entire virtualport)
      
      * add a REQUIRE_TYPE flag to the parser - if this flag is set, the
        parser will return an error if the virtualport has no type
        attribute. This also was previously the default behavior, but isn't
        needed in the case of the virtualport for a type='network' interface
        (i.e. the exact type isn't yet known), or the virtualport of a
        portgroup (i.e. the portgroup just has modifiers for the network's
        virtualport, which *does* require a type) - in those cases, the
        check will be done at domain startup, once the final virtualport is
        assembled (this is handled in the next patch).
      4af3cbaf
    • L
      conf: simplify Buffer Indentation in virDomainNetDefFormat · ff1efc09
      Laine Stump 提交于
      This function has several calls to increase the buffer indent by 6,
      then decrease it again, then increase, then decrease. Additionally,
      there were several printfs that had 6 spaces at the beginning of the
      line.
      
      virDomainActualNetDefFormat, which is called by virDomainNetDefFormat,
      had similar ugliness.
      
      This patch changes both functions to just increase the indent at the
      beginning, decrease it at (well, just before*) the end, and remove all
      of the occurences of 6/8 spaces at the beginning of lines.
      
      *The indent had to be reset before the end of the function because
      virDomainDeviceInfoFormat assumes a 0 indent and is called from many
      other places, and I didn't want to do an overhaul of every caller of
      that function. A separate patch to switch all of domain_conf.c would
      be a useful exercise, but my current goal is unrelated to that, so
      I'll leave it for another day.
      ff1efc09
    • L
      conf: make error returns from virDomainActualNetDefFormat consistent · 2841a0ad
      Laine Stump 提交于
      There was an error: label that simply did "return ret", but ret was
      defaulted to -1, and was never used other than setting it manually to
      0 just before a non-error return. Aside from this, some of the error
      return paths used "goto error" and others used "return ret".
      
      This patch removes ret and the error: label, and makes all error
      returns just consistently do "return -1".
      2841a0ad
    • L
      conf: move virtPortProfile out of unions in virDomainNetDef · 1d174428
      Laine Stump 提交于
      virtPortProfile is now used by 4 different types of network devices
      (NETWORK, BRIDGE, DIRECT, and HOSTDEV), and it's getting cumbersome to
      replicate so much code in 4 different places just because each type
      has the virtPortProfile in a slightly different place. This patch puts
      a single virtPortProfile in a common place (outside the type-specific
      union) in both virDomainNetDef and virDomainActualNetDef, and adjusts
      the parse and format code (and the few other places where it is used)
      accordingly.
      
      Note that when a <virtualport> element is found, the parse functions
      verify that the interface is of a type that supports one, otherwise an
      error is generated (CONFIG_UNSUPPORTED in the case of <interface>, and
      INTERNAL in the case of <actual>, since the contents of <actual> are
      always generated by libvirt itself).
      1d174428
    • L
      util: eliminate union in virNetDevVPortProfile · 21ea73e8
      Laine Stump 提交于
      virNetDevVPortProfile has (had) a type field that can be set to one of
      several values, and a union of several structs, one for each
      type. When a domain's interface object is of type "network", the
      domain config may not know beforehand which type of virtualport is
      going to be provided in the actual device handed down from the network
      driver at runtime, but may want to set some values in the virtualport
      that may or may not be used, depending on the type. To support this
      usage, this patch replaces the union of structs with toplevel fields
      in the struct, making it possible for all of the fields to be set at
      the same time.
      21ea73e8
  12. 14 8月, 2012 1 次提交
    • O
      Destroy virdomainlist.[ch] · bb705e25
      Osier Yang 提交于
      As the consensus in:
      https://www.redhat.com/archives/libvir-list/2012-July/msg01692.html,
      this patch is to destroy conf/virdomainlist.[ch], folding the
      helpers into conf/domain_conf.[ch].
      
      * src/Makefile.am:
        - Various indention fixes incidentally
        - Add macro DATATYPES_SOURCES (datatypes.[ch])
        - Link datatypes.[ch] for libvirt_lxc
      
      * src/conf/domain_conf.c:
        - Move all the stuffs from virdomainlist.c into it
        - Use virUnrefDomain and virUnrefDomainSnapshot instead of
          virDomainFree and virDomainSnapshotFree, which are defined
          in libvirt.c, and we don't want to link to it.
        - Remove "if" before "free" the object, as virObjectUnref
          is in the list "useless_free_options".
      
      * src/conf/domain_conf.h:
        - Move all the stuffs from virdomainlist.h into it
        - s/LIST_FILTER/LIST_DOMAINS_FILTER/
      
      * src/libxl/libxl_driver.c:
        - s/LIST_FILTER/LIST_DOMAINS_FILTER/
        - no (include "virdomainlist.h")
      
      * src/libxl/libxl_driver.c: Likewise
      
      * src/lxc/lxc_driver.c: Likewise
      
      * src/openvz/openvz_driver.c: Likewise
      
      * src/parallels/parallels_driver.c: Likewise
      
      * src/qemu/qemu_driver.c: Likewise
      
      * src/test/test_driver.c: Likewise
      
      * src/uml/uml_driver.c: Likewise
      
      * src/vbox/vbox_tmpl.c: Likewise
      
      * src/vmware/vmware_driver.c: Likewise
      
      * tools/virsh-domain-monitor.c: Likewise
      
      * tools/virsh.c: Likewise
      bb705e25
  13. 10 8月, 2012 1 次提交
    • L
      nwfilter: fix crash during filter define when lxc driver failed startup · b8a56f12
      Laine Stump 提交于
      The meat of this patch is just moving the calls to
      virNWFilterRegisterCallbackDriver from each hypervisor's "register"
      function into its "initialize" function. The rest is just code
      movement to allow that, and a new virNWFilterUnRegisterCallbackDriver
      function to undo what the register function does.
      
      The long explanation:
      
      There is an array in nwfilter called callbackDrvArray that has
      pointers to a table of functions for each hypervisor driver that are
      called by nwfilter. One of those function pointers is to a function
      that will lock the hypervisor driver. Entries are added to the table
      by calling each driver's "register" function, which happens quite
      early in libvirtd's startup.
      
      Sometime later, each driver's "initialize" function is called. This
      function allocates a driver object and stores a pointer to it in a
      static variable that was previously initialized to NULL. (and here's
      the important part...) If the "initialize" function fails, the driver
      object is freed, and that pointer set back to NULL (but the entry in
      nwfilter's callbackDrvArray is still there).
      
      When the "lock the driver" function mentioned above is called, it
      assumes that the driver was successfully loaded, so it blindly tries
      to call virMutexLock on "driver->lock".
      
      BUT, if the initialize never happened, or if it failed, "driver" is
      NULL. And it just happens that "lock" is always the first field in
      driver so it is also NULL.
      
      Boom.
      
      To fix this, the call to virNWFilterRegisterCallbackDriver for each
      driver shouldn't be called until the end of its (*already guaranteed
      successful*) "initialize" function, not during its "register" function
      (which is currently the case). This implies that there should also be
      a virNWFilterUnregisterCallbackDriver() function that is called in a
      driver's "shutdown" function (although in practice, that function is
      currently never called).
      b8a56f12