1. 06 2月, 2013 10 次提交
    • D
      Protect USB/PCI device list access in QEMU with dedicated locks · 011cf7ad
      Daniel P. Berrange 提交于
      Currently the activePciHostdevs, inactivePciHostdevsd and
      activeUsbHostdevs lists are all implicitly protected by the
      QEMU driver lock. Now that the lists all inherit from the
      virObjectLockable, we can make the locking explicit, removing
      the dependency on the QEMU driver lock for correctness.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      011cf7ad
    • D
      Convert virPCIDeviceList and virUSBDeviceList into virObjectLockable · 0f9ef558
      Daniel P. Berrange 提交于
      To allow modifications to the lists to be synchronized, convert
      virPCIDeviceList and virUSBDeviceList into virObjectLockable
      classes. The locking, however, will not be self-contained. The
      users of these classes will have to call virObjectLock/Unlock
      in the critical regions.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0f9ef558
    • D
      Rename all USB device functions to have a standard name prefix · 77c3015f
      Daniel P. Berrange 提交于
      Rename all the usbDeviceXXX and usbXXXDevice APIs to have a
      fixed virUSBDevice name prefix
      77c3015f
    • D
      Fix leak of usbDevice struct when initializing cgroups · 3e86e8f3
      Daniel P. Berrange 提交于
      When iterating over USB host devices to setup cgroups, the
      usbDevice object was leaked in both LXC and QEMU driers
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3e86e8f3
    • D
      Rename all PCI device functions to have a standard name prefix · 20253560
      Daniel P. Berrange 提交于
      Rename all the pciDeviceXXX and pciXXXDevice APIs to have a
      fixed virPCIDevice name prefix
      20253560
    • D
      Remove pointless 'qemuVersion' field from virQEMUDriverPtr · b46f7f4a
      Daniel P. Berrange 提交于
      The QEMU driver struct has a 'qemuVersion' field that was previously
      used to cache the version lookup from capabilities. With the recent
      QEMU capabilities rewrite the caching happens at a lower level so
      this field is pointless. Removing it avoids worries about locking
      when updating it.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b46f7f4a
    • D
      Use atomic ops to increment nextvmid · 6ffcab65
      Daniel P. Berrange 提交于
      Use atomic ops to increment nextvmid and encapsulate it in a
      method to prevent accidental non-atomic access
      6ffcab65
    • D
      Make virDomainObjList self-locking via virObjectLockable · 582c445a
      Daniel P. Berrange 提交于
      Switch virDomainObjList to inherit from virObjectLockable and
      make all the APIs acquire/release the mutex when running. This
      makes virDomainObjList completely self-locking and no longer
      reliant on the hypervisor driver locks
      582c445a
    • D
      Merge virDomainObjListIsDuplicate into virDomainObjListAdd · eea87129
      Daniel P. Berrange 提交于
      The duplicate VM checking should be done atomically with
      virDomainObjListAdd, so shoud not be a separate function.
      Instead just use flags to indicate what kind of checks are
      required.
      
      This pair, used in virDomainCreateXML:
      
         if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
           goto cleanup;
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def, false)))
           goto cleanup;
      
      Changes to
      
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def,
                                         VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
                                         NULL)))
           goto cleanup;
      
      This pair, used in virDomainRestoreFlags:
      
         if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
           goto cleanup;
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def, true)))
           goto cleanup;
      
      Changes to
      
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def,
                                         VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
                                         VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
                                         NULL)))
           goto cleanup;
      
      This pair, used in virDomainDefineXML:
      
         if (virDomainObjListIsDuplicate(privconn->domains, def, 0) < 0)
           goto cleanup;
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def, false)))
           goto cleanup;
      
      Changes to
      
         if (!(dom = virDomainObjListAdd(privconn->domains,
                                         privconn->caps,
                                         def,
                                         0, NULL)))
           goto cleanup;
      eea87129
    • E
      qemu: don't log failure during QMP add-fd probe · 753020dc
      Eric Blake 提交于
      Otherwise, we get a lot of scary (but harmless) noise in the logs:
      
      2013-02-05 15:35:48.555+0000: 8637: error : qemuMonitorJSONCheckError:353 : internal error unable to execute QEMU command 'add-fd': Parameter 'fdset-id' expects an existing fdset-id
      
      one for every qemu 1.2 binary that we probe.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd): During
      probe, avoid logging failures.
      753020dc
  2. 05 2月, 2013 11 次提交
    • D
      Turn virDomainObjList into an opaque virObject · 37abd471
      Daniel P. Berrange 提交于
      As a step towards making virDomainObjList thread-safe turn it
      into an opaque virObject, preventing any direct access to its
      internals.
      
      As part of this a new method virDomainObjListForEach is
      introduced to replace all existing usage of virHashForEach
      37abd471
    • D
      Rename all domain list APIs to have virDomainObjList prefix · 4f6ed6c3
      Daniel P. Berrange 提交于
      The APIs names for accessing the domain list object are
      very inconsistent. Rename them all to have a standard
      virDomainObjList prefix.
      4f6ed6c3
    • D
      Introduce a virQEMUDriverConfigPtr object · b090aa7d
      Daniel P. Berrange 提交于
      Currently the virQEMUDriverPtr struct contains an wide variety
      of data with varying access needs. Move all the static config
      data into a dedicated virQEMUDriverConfigPtr object. The only
      locking requirement is to hold the driver lock, while obtaining
      an instance of virQEMUDriverConfigPtr. Once a reference is held
      on the config object, it can be used completely lockless since
      it is immutable.
      
      NB, not all APIs correctly hold the driver lock while getting
      a reference to the config object in this patch. This is safe
      for now since the config is never updated on the fly. Later
      patches will address this fully.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b090aa7d
    • M
      qemu: Catch stderr of image compression binary · 137229bf
      Michal Privoznik 提交于
      If a compression binary prints something to stderr, currently
      it is discarded. However, it can contain useful data from
      debugging POV, so we should catch it.
      137229bf
    • M
      qemu: Catch stderr of image decompression binary · cc6c425f
      Michal Privoznik 提交于
      If a decompression binary prints something to stderr, currently
      it is discarded. However, it can contain useful data from
      debugging POV, so we should catch it.
      cc6c425f
    • M
      virFileWrapperFd: Switch to new virCommandDoAsyncIO · 1f25194a
      Michal Privoznik 提交于
      Commit 34e8f63a introduced support for catching errors from
      libvirt iohelper. However, at those times there wasn't such fancy
      API as virCommandDoAsyncIO(), so everything has to be implemented
      on our own. But since we do have the API now, we can use it and
      drop our implementation then.
      1f25194a
    • M
      virCommand: Introduce virCommandDoAsyncIO · 68fb7550
      Michal Privoznik 提交于
      Currently, if we want to feed stdin, or catch stdout or stderr of a
      virCommand we have to use virCommandRun(). When using virCommandRunAsync()
      we have to register FD handles by hand. This may lead to code duplication.
      Hence, introduce an internal API, which does this automatically within
      virCommandRunAsync(). The intended usage looks like this:
      
          virCommandPtr cmd = virCommandNew*(...);
          char *buf = NULL;
      
          ...
      
          virCommandSetOutputBuffer(cmd, &buf);
          virCommandDoAsyncIO(cmd);
      
          if (virCommandRunAsync(cmd, NULL) < 0)
              goto cleanup;
      
          ...
      
          if (virCommandWait(cmd, NULL) < 0)
              goto cleanup;
      
          /* @buf now contains @cmd's stdout */
          VIR_DEBUG("STDOUT: %s", NULLSTR(buf));
      
          ...
      
      cleanup:
          VIR_FREE(buf);
          virCommandFree(cmd);
      
      Note, that both stdout and stderr buffers may change until virCommandWait()
      returns.
      68fb7550
    • P
      conf: Use correct type for device type enum in virDomainDeviceDefFree · 8a3cf528
      Peter Krempa 提交于
      With this change it's easy to spot a forgotten free if a new device
      class is added.
      8a3cf528
    • J
      build: Add libcurl dependency to libvirt_driver.la · 514b9306
      Jiri Denemark 提交于
      libvirt.c calls curl_global_init() if WITH_CURL is defined and thus it
      should be linked with libcurl. This fixes link failure in case neither
      xenapi nor esx driver is enabled (they are the only users of libcurl).
      514b9306
    • M
      Add basic support for VDI images · 027bf2ea
      Martin Kletzander 提交于
      QEMU is fully capable of handling VDI images and we just refuse to
      work with them.  As qemu-img knows and supports this, there should be
      no problem with this addition.
      
      This is of course, just basic functionality, without searching for any
      backing files, etc.
      027bf2ea
    • M
      Support shifted magic in storage files · a0f98229
      Martin Kletzander 提交于
      Some files have the magic shifted to some offset other than 0, so we
      have to support that.  I also cleaned up some lines to be more
      readable and added missing magic for iso file format.
      a0f98229
  3. 02 2月, 2013 3 次提交
    • M
      e7aa207c
    • M
      esx: Simplify esxPrivate pointer handling in esxOpen · ee47d236
      Matthias Bolte 提交于
      Commit 4445e16b changed the signature
      of esxConnectToHost and esxConnectToVCenter by replacing the esxPrivate
      pointer with virConnectPtr. The esxPrivate pointer was then retrieved
      again from virConnectPtr's privateData. This resulted in a NULL pointer
      dereference, because the privateData pointer was not yet initialized at
      the point where esxConnectToHost and esxConnectToVCenter are called.
      
      This was fixed in commit b126715a that
      moved the initialization of privateData before the problematic calls.
      
      Simplify the logic by making the call to esxFreePrivate unconditional and
      changing esxConnectToHost and esxConnectToVCenter back to take a esxPrivate
      pointer directly. This allows to assign esxPrivate to the virConnectPtr's
      privateData pointer as one of the last steps in esxOpen making it more
      obvious that it is not initialized during the earlier steps of esxOpen.
      ee47d236
    • E
      docs: don't ignore virEvent API · b2aa03b3
      Eric Blake 提交于
      Commit 6094ad7b (0.9.3 release) promoted several functions from
      internal to public, but forgot to fix the documentation generator
      to provide details about those functions.
      
      For an example of what this fixes, look at:
      file:///path/to/libvirt/docs/html/libvirt-libvirt.html#virEventAddHandle
      before and after the patch.
      
      * docs/apibuild.py (ignored_functions): Don't ignore functions
      that were turned into official API.
      * src/util/virevent.c: Fix comments to pass through parser.
      b2aa03b3
  4. 01 2月, 2013 2 次提交
    • S
      Add support for QEMU -add-fd support detection · 410b335d
      Stefan Berger 提交于
      Add support for QEMU -add-fd command line parameter detection.
      This intentionally rejects qemu 1.2, where 'add-fd' QMP did
      not allow full control of set ids, and where there was no command
      line counterpart, but accepts qemu 1.3.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      410b335d
    • E
      qemu: expose qemu 1.3 add-fd monitor command · 7b2c5893
      Eric Blake 提交于
      Add entry points for calling the qemu 'add-fd' and 'remove-fd'
      monitor commands.  There is no entry point for 'query-fdsets';
      the assumption is that a developer can use
       virsh qemu-monitor-command domain '{"execute":"query-fdsets"}'
      when debugging issues, and that meanwhile, libvirt is responsible
      enough to remember what fds it associated with what fdsets.
      Likewise, on the 'add-fd' command, it is assumed that libvirt
      will always pass a set id, rather than letting qemu autogenerate
      the next available id number.
      
      * src/qemu/qemu_monitor.c (qemuMonitorAddFd, qemuMonitorRemoveFd):
      New functions.
      * src/qemu/qemu_monitor.h (qemuMonitorAddFd, qemuMonitorRemoveFd):
      New prototypes.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd)
      (qemuMonitorJSONRemoveFd): New functions.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONAddFd)
      (qemuMonitorJSONRemoveFd): New prototypes.
      7b2c5893
  5. 31 1月, 2013 1 次提交
    • J
      Enforce return check on virAsprintf() calls · 46b1d8cf
      John Ferlan 提交于
      Way back when I started making changes for Coverity messages my first set
      were to a bunch of CHECKED_RETURN errors.  In particular virAsprintf() had
      a few callers that Coverity noted didn't check their return (although some
      did check if the buffer being printed to was NULL or not).
      
      It was suggested at the time as a further patch an ATTRIBUTE_RETURN_CHECK
      should be added to virAsprintf(), see:
      
      https://www.redhat.com/archives/libvir-list/2013-January/msg00120.html
      
      This patch does that and fixes a few more instances not found by Coverity
      that failed the check.
      46b1d8cf
  6. 30 1月, 2013 5 次提交
    • J
      util: Fix mask for 172.16.0.0 private address range · 6405713f
      Jiri Denemark 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=905708
      
      Only the first 12 bits should be set in the mask for this range. All
      addresses between 172.16.0.0 and 172.31.255.255 are private.
      6405713f
    • P
      snapshot: Mention disk-only snapshots in error message · 366a3d52
      Peter Krempa 提交于
      When a disk-only snapshot is requested the domain is treated as if it
      was offline. This forbids to mix memory checkpoints with the DISK_ONLY
      flag.
      
      This patch improves the error message and mentions the restriction in
      the virsh man page.
      366a3d52
    • M
      docs: aesthetical cleanups · 901f4b6b
      Martin Kletzander 提交于
      Adding dots inside "exempli gratia" where missing.  While on that, I
      took the liberty of changing it where found with simple grep.
      901f4b6b
    • M
      conf: Don't format cputune element when not needed · 1f50730e
      Martin Kletzander 提交于
      Commit 60b176c3 introduced a bug that
      when editing an XML with cputune similar to this:
      
      ...
        <vcpu placement='static' current='1'>2</vcpu>
        <cputune>
          <vcpupin vcpu="1" cpuset="0"/>
        </cputune>
      ...
      
      results in formatted XML that looks like this:
      
      ...
        <vcpu placement='static' current='1'>2</vcpu>
        <cputune>
        </cputune>
      ...
      
      That is caused by a condition depending on def->cputune.vcpupin being
      set rather than checking def->cputune.nvcpupin.  Notice that nvcpupin
      can be 0 and vcpupin can still be allocated since it's a pointer to an
      array, so no harm done there.
      
      I also changed it on other places in the code where it depended on the
      wrong variable.
      1f50730e
    • D
      virlog: remove old code comment · 1c23ba28
      Doug Goldstein 提交于
      Setting the log output prefix to 0 is not supported and in fact results
      in the following message:
      warning : virLogParseOutputs:1021 : Ignoring invalid log output setting.
      1c23ba28
  7. 29 1月, 2013 3 次提交
  8. 27 1月, 2013 2 次提交
  9. 26 1月, 2013 3 次提交
    • J
      vbox: Adjust the UTF FREE macros · 97278ab4
      John Ferlan 提交于
      Adjust the macros to free memory allocated during various calls to
      perform the check if parameter is NULL prior to really freeing and to
      set the pointer to NULL after done freeing.
      97278ab4
    • J
      vbox: Address false positive for NULL dereference · 4f01d3d5
      John Ferlan 提交于
      Resolve a false positive from 'vboxIIDFromUUID_v2_x()'. The code sets
      'iid->value = &iid->backing' unconditionally prior to calling 'nsIDFromChar()'.
      The 'vboxIIDUnalloc_v2_x()' checks iid->value to not be &iid->backing. The
      iid->backing is a static buffer within the initialized structure.
      4f01d3d5
    • J
      libxl: Domain event handler improvements · 70291149
      Jim Fehlig 提交于
      Since libxl provides the domain ID in the event handler callback,
      find the domain object based on the ID.  This approach prevents
      processing the callback on a domain that has already been reaped.
      
      Also, similar to the xl implementation, ignore the SUSPEND shutdown
      reason.  By calling libxl_domain_suspend(), we know a shutdown
      event with SUSPEND reason will be generated, but it can be safely
      ignored since any subsequent cleanup will be done by the callers.
      70291149