1. 30 6月, 2016 1 次提交
  2. 13 6月, 2013 3 次提交
    • C
      qemu: Don't report error on successful media eject · f8085a54
      Cole Robinson 提交于
      If we are just ejecting media, ret == -1 even after the retry loop
      determines that the tray is open, as requested. This means media
      disconnect always report's error.
      
      Fix it, and fix some other mini issues:
      
      - Don't overwrite the 'eject' error message if the retry loop fails
      - Move the retries decrement inside the loop, otherwise the final loop
        might succeed, yet retries == 0 and we will raise error
      - Setting ret = -1 in the disk->src check is unneeded
      - Fix comment typos
      
      cc: mprivozn@redhat.com
      (cherry picked from commit 406d8a98)
      f8085a54
    • M
      qemuDomainChangeEjectableMedia: Unlock domain while waiting for event · a93f2757
      Michal Privoznik 提交于
      In 84c59ffa I've tried to fix changing ejectable media process. The
      process should go like this:
      
      1) we need to call 'eject' on the monitor
      2) we should wait for 'DEVICE_TRAY_MOVED' event
      3) now we can issue 'change' command
      
      However, while waiting in step 2) the domain monitor was locked. So
      even if qemu reported the desired event, the proper callback was not
      called immediately. The monitor handling code needs to lock the
      monitor in order to read the event. So that's the first lock we must
      not hold while waiting. The second one is the domain lock. When
      monitor handling code reads an event, the appropriate callback is
      called then. The first thing that each callback does is locking the
      corresponding domain as a domain or its device is about to change
      state. So we need to unlock both monitor and VM lock. Well, holding
      any lock while sleep()-ing is not the best thing to do anyway.
      (cherry picked from commit 543af79a)
      
      Conflicts:
      	src/qemu/qemu_hotplug.c
      a93f2757
    • M
      qemu_hotplug: Rework media changing process · 7c4b6833
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=892289
      
      It seems like with new udev within guest OS, the tray is locked,
      so we need to:
      - 'eject'
      - wait for tray to open
      - 'change'
      
      Moreover, even when doing bare 'eject', we should check for
      'tray_open' as guest may have locked the tray. However, the
      waiting phase shouldn't be unbounded, so I've chosen 10 retries
      maximum, each per 500ms. This should give enough time for guest
      to eject a media and open the tray.
      (cherry picked from commit 84c59ffa)
      7c4b6833
  3. 21 9月, 2012 2 次提交
  4. 13 9月, 2012 3 次提交
    • D
      Turn QEMU capabilities object into a full virObjectPtr · beac09fd
      Daniel P. Berrange 提交于
      The current qemu capabilities are stored in a virBitmapPtr
      object, whose type is exposed to callers. We want to store
      more data besides just the flags, so we need to move to a
      struct type. This object will also need to be reference
      counted, since we'll be maintaining a cache of data per
      binary. This change introduces a 'qemuCapsPtr' virObject
      class. Most of the change is just renaming types and
      variables in all the callers
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      beac09fd
    • G
      qemu: build USB redirection filter qemu command line · 2d46f88d
      Guannan Ren 提交于
      Input XML snip:
      <redirdev bus='usb' type='spicevmc'>
         <address type='usb' bus='0' port='4'/>
       </redirdev>
      <redirfilter>
        <usbdev class='0x08' vendor='0x1234' product='0xbeef' \
                version='2.00' allow='yes'/>
        <usbdev class='-1' vendor='-1' product='-1' version='-1' allow='no'/>
      </redirfilter>
      
      will be converted to:
      -device usb-redir,chardev=charredir0,id=redir0,\
      filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4
      2d46f88d
    • E
      maint: fix missing spaces in message · 2387aa26
      Eric Blake 提交于
      I got an off-list report about a bad diagnostic:
      Target network card mac 52:54:00:49:07:ccdoes not match source 52:54:00:49:07:b8
      
      True to form, I've added a syntax check rule to prevent it
      from recurring, and found several other offenders.
      
      * cfg.mk (sc_require_whitespace_in_translation): New rule.
      * src/conf/domain_conf.c (virDomainNetDefCheckABIStability): Add
      space.
      * src/esx/esx_util.c (esxUtil_ParseUri): Likewise.
      * src/qemu/qemu_command.c (qemuCollectPCIAddress): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSetMetadata)
      (qemuDomainGetMetadata): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainChangeNetBridge): Likewise.
      * src/rpc/virnettlscontext.c
      (virNetTLSContextCheckCertDNWhitelist): Likewise.
      * src/vmware/vmware_driver.c (vmwareDomainResume): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives):
      Avoid false negatives.
      * tools/virsh-domain.c (info_save_image_dumpxml): Reword.
      Based on a report by Luwen Su.
      2387aa26
  5. 03 9月, 2012 1 次提交
  6. 18 8月, 2012 1 次提交
  7. 15 8月, 2012 1 次提交
    • 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
  8. 06 8月, 2012 1 次提交
  9. 03 8月, 2012 1 次提交
    • O
      qemu: Allow to attach/detach controller device persistently · ed1e711b
      Osier Yang 提交于
      * src/conf/domain_conf.c:
        - Add virDomainControllerFind to find controller device by type
          and index.
        - Add virDomainControllerRemove to remove the controller device
          from maintained controler list.
      
      * src/conf/domain_conf.h:
        - Declare the two new helpers.
      
      * src/libvirt_private.syms:
        - Expose private symbols for the two new helpers.
      
      * src/qemu/qemu_driver.c:
        - Support attach/detach controller device persistently
      
      * src/qemu/qemu_hotplug.c:
        - Use the two helpers to simplify the codes.
      ed1e711b
  10. 01 8月, 2012 1 次提交
  11. 31 7月, 2012 1 次提交
    • E
      qemu: fix use after free · 665c8cde
      Eric Blake 提交于
      Detected by Coverity.
      
      * src/qemu/qemu_hotplug.c (qemuDomainAttachHostDevice): Avoid
      double free of usb on failure.
      665c8cde
  12. 27 7月, 2012 1 次提交
    • E
      maint: don't permit format strings without % · 768007ae
      Eric Blake 提交于
      Any time we have a string with no % passed through gettext, a
      translator can inject a % to cause a stack overread.  When there
      is nothing to format, it's easier to ask for a string that cannot
      be used as a formatter, by using a trivial "%s" format instead.
      
      In the past, we have used --disable-nls to catch some of the
      offenders, but that doesn't get run very often, and many more
      uses have crept in.  Syntax check to the rescue!
      
      The syntax check can catch uses such as
      virReportError(code,
                     _("split "
                       "string"));
      by using a sed script to fold context lines into one pattern
      space before checking for a string without %.
      
      This patch is just mechanical insertion of %s; there are probably
      several messages touched by this patch where we would be better
      off giving the user more information than a fixed string.
      
      * cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
      * src/datatypes.c (virUnrefConnect, virGetDomain)
      (virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
      (virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
      (virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
      (virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
      (virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
      * src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
      (lxcDomainGetBlkioParameters): Likewise.
      * src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
      (virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
      Likewise.
      * src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
      (virNetworkDefParseXML): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
      Likewise.
      * src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
      (virNWFilterVarAccessParse): Likewise.
      * src/libvirt.c (virDomainSave, virDomainSaveFlags)
      (virDomainRestore, virDomainRestoreFlags)
      (virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
      (virDomainCoreDump, virDomainGetXMLDesc)
      (virDomainMigrateVersion1, virDomainMigrateVersion2)
      (virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
      (virStreamSendAll, virStreamRecvAll)
      (virDomainSnapshotGetXMLDesc): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
      (virNWFilterDHCPSnoopReq): Likewise.
      * src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
      * src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
      * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
      * src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
      (qemuBuildCommandLine): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
      * src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
      Likewise.
      * src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
      (virNetSocketSendFD, virNetSocketRecvFD): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskBuildPool): Likewise.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemProbe)
      (virStorageBackendFileSystemBuild): Likewise.
      * src/storage/storage_backend_rbd.c
      (virStorageBackendRBDOpenRADOSConn): Likewise.
      * src/storage/storage_driver.c (storageVolumeResize): Likewise.
      * src/test/test_driver.c (testInterfaceChangeBegin)
      (testInterfaceChangeCommit, testInterfaceChangeRollback):
      Likewise.
      * src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
      * src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
      Likewise.
      * src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
      (xenFormatXM): Likewise.
      768007ae
  13. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  14. 19 7月, 2012 3 次提交
  15. 17 7月, 2012 1 次提交
    • S
      Convert 'raw MAC address' usages to use virMacAddr · 387117ad
      Stefan Berger 提交于
      Introduce new members in the virMacAddr 'class'
      - virMacAddrSet: set virMacAddr from a virMacAddr
      - virMacAddrSetRaw: setting virMacAddr from raw 6 byte MAC address buffer
      - virMacAddrGetRaw: writing virMacAddr into raw 6 byte MAC address buffer
      - virMacAddrCmp: comparing two virMacAddr
      - virMacAddrCmpRaw: comparing a virMacAddr with a raw 6 byte MAC address buffer
      
      then replace raw MAC addresses by replacing
      
      - 'unsigned char *' with virMacAddrPtr
      - 'unsigned char ... [VIR_MAC_BUFLEN]' with virMacAddr
      
      and introduce usage of above functions where necessary.
      387117ad
  16. 14 6月, 2012 1 次提交
    • P
      qemu: Enable disconnecting SPICE clients without changing password · e0f0131d
      Peter Krempa 提交于
      Libvirt updates the configuration of SPICE server only when something
      changes. This is unfortunate when the user wants to disconnect a
      existing spice session when the connected attribute is already
      "disconnect".
      
      This patch modifies the conditions for calling the password updater to
      be called when nothing changes, but the connected attribute is already
      "disconnect".
      e0f0131d
  17. 23 5月, 2012 1 次提交
    • P
      qemu_hotplug: Don't free the PCI device structure after hot-unplug · db19417f
      Peter Krempa 提交于
      The pciDevice structure corresponding to the device being hot-unplugged
      was freed after it was "stolen" from activeList. The pointer was still
      used for eg-inactive list. This patch removes the free of the structure
      and frees it only if reset fails on the device.
      db19417f
  18. 17 5月, 2012 1 次提交
    • M
      qemu: Don't delete USB device on failed qemuPrepareHostdevUSBDevices · 9c484e3d
      Michal Privoznik 提交于
      If qemuPrepareHostdevUSBDevices fail it will roll back devices added
      to the driver list of used devices. However, if it may fail because
      the device is being used already. But then again - with roll back.
      Therefore don't try to remove a usb device manually if the function
      fail. Although, we want to remove the device if any operation
      performed afterwards fail.
      9c484e3d
  19. 11 5月, 2012 1 次提交
    • G
      usb: fix crash when failing to attach a second usb device · ab5fb8f3
      Guannan Ren 提交于
      when failing to attach another usb device to a domain for some reason
      which has one use device attached before, the libvirtd crashed.
      The crash is caused by null-pointer dereference error in invoking
      usbDeviceListSteal passed in NULL value usb variable.
      commit 05abd150 introduces the bug.
      ab5fb8f3
  20. 07 5月, 2012 2 次提交
    • G
      qemu: call usb search function for hostdev initialization and hotplug · 05abd150
      Guannan Ren 提交于
      src/qemu/qemu_hostdev.c:
      refactor qemuPrepareHostdevUSBDevices function, make it focus on
      adding usb device to activeUsbHostdevs after check. After that,
      the usb hotplug function qemuDomainAttachHostDevice also could use
      it.
      expand qemuPrepareHostUSBDevices to perform the usb search,
      rollback on failure.
      
      src/qemu/qemu_hotplug.c:
      If there are multiple usb devices available with same vendorID and productID,
      but with different value of "bus, device", we give an error to let user
      use <address> to specify the desired one.
      05abd150
    • G
      usb: create functions to search usb device accurately · 9914477e
      Guannan Ren 提交于
      usbFindDevice():get usb device according to
                      idVendor, idProduct, bus, device
                      it is the exact match of the four parameters
      
      usbFindDeviceByBus():get usb device according to bus, device
                        it returns only one usb device same as usbFindDevice
      
      usbFindDeviceByVendor():get usb device according to idVendor,idProduct
                           it probably returns multiple usb devices.
      
      usbDeviceSearch(): a helper function to do the actual search
      9914477e
  21. 18 4月, 2012 1 次提交
    • E
      qemu: use consistent error when qemu binary is too old · 6fb8a64d
      Eric Blake 提交于
      Most of our errors complaining about an inability to support a
      particular action due to qemu limitations used CONFIG_UNSUPPORTED,
      but we had a few outliers.  Reported by Jiri Denemark.
      
      * src/qemu/qemu_command.c (qemuBuildDriveDevStr): Prefer
      CONFIG_UNSUPPORTED.
      * src/qemu/qemu_driver.c (qemuDomainReboot)
      (qemuDomainBlockJobImpl): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachPciControllerDevice):
      Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorTransaction)
      (qemuMonitorBlockJob, qemuMonitorSystemWakeup): Likewise.
      6fb8a64d
  22. 03 4月, 2012 1 次提交
    • J
      qemu: Start nested job in qemuDomainCheckEjectableMedia · 66cab01a
      Jiri Denemark 提交于
      Originally, qemuDomainCheckEjectableMedia was entering monitor with qemu
      driver lock. Commit 2067e31b, which I
      made to fix that, revealed another issue we had (but didn't notice it
      since the driver was locked): we didn't set nested job when
      qemuDomainCheckEjectableMedia is called during migration. Thus the
      original fix I made was wrong.
      66cab01a
  23. 31 3月, 2012 1 次提交
  24. 30 3月, 2012 1 次提交
  25. 27 3月, 2012 1 次提交
    • J
      qemu: Avoid entering monitor with locked driver · 2067e31b
      Jiri Denemark 提交于
      This avoids possible deadlock of the qemu driver in case a domain is
      begin migrated (in Begin phase) and unrelated connection to qemu driver
      is closed at the right time.
      
      I checked all callers of qemuDomainCheckEjectableMedia() and they are
      calling this function with qemu driver locked.
      2067e31b
  26. 16 3月, 2012 1 次提交
  27. 13 3月, 2012 1 次提交
    • G
      qemu: fix segfault when detaching non-existent network device · 19c7980e
      Guannan Ren 提交于
      In qemuDomainDetachNetDevice, detach was being used before it had been
      validated. If no matching device was found, this resulted in a
      dereference of a NULL pointer.
      
      This behavior was a regression introduced in commit
      cf90342b, so it has not been a part of
      any official libvirt release.
      19c7980e
  28. 09 3月, 2012 2 次提交
    • L
      util: eliminate device object leaks related to virDomain*Remove*() · f985773d
      Laine Stump 提交于
      There are several functions in domain_conf.c that remove a device
      object from the domain's list of that object type, but don't free the
      object or return it to the caller to free. In many cases this isn't a
      problem because the caller already had a pointer to the object and
      frees it afterward, but in several cases the removed object was just
      left floating around with no references to it.
      
      In particular, the function qemuDomainDetachDeviceConfig() calls
      functions to locate and remove net (virDomainNetRemoveByMac), disk
      (virDomainDiskRemoveByName()), and lease (virDomainLeaseRemove())
      devices, but neither it nor its caller qemuDomainModifyDeviceConfig()
      ever obtain a pointer to the device being removed, much less free it.
      
      This patch modifies the following "remove" functions to return a
      pointer to the device object being removed from the domain device
      arrays, to give the caller the option of freeing the device object
      using that pointer if needed. In places where the object was
      previously leaked, it is now freed:
      
        virDomainDiskRemove
        virDomainDiskRemoveByName
        virDomainNetRemove
        virDomainNetRemoveByMac
        virDomainHostdevRemove
        virDomainLeaseRemove
        virDomainLeaseRemoveAt
      
      The functions that had been leaking:
      
        libxlDomainDetachConfig - leaked a virDomainDiskDef
        qemuDomainDetachDeviceConfig - could leak a virDomainDiskDef,
                                  a virDomainNetDef, or a
                                  virDomainLeaseDef
        qemuDomainDetachLease   - leaked a virDomainLeaseDef
      f985773d
    • L
      qemu: don't 'remove' hostdev objects from domain if operation fails · b59e5984
      Laine Stump 提交于
      There were certain paths through the hostdev detach code that could
      lead to the lower level function failing (and not removing the object
      from the domain's hostdevs list), but the higher level function
      free'ing the hostdev object anyway. This would leave a stale
      hostdevdef pointer in the list, which would surely cause a problem
      eventually.
      
      This patch relocates virDomainHostdevRemove from the lower level
      functions qemuDomainDetachThisHostDevice and
      qemuDomainDetachHostPciDevice, to their caller
      qemuDomainDetachThisHostDevice, placing it just before the call to
      virDomainHostdevDefFree. This makes it easy to verify that either both
      operations are done, or neither.
      
      NB: The "dangling pointer" part of this problem was introduced in
      commit 13d5a6, so it is not present in libvirt versions prior to
      0.9.9. Earlier versions would return failure in certain cases even
      though the the device object was removed/deleted, but the removal and
      deletion operations would always both happen or neither.
      b59e5984
  29. 06 3月, 2012 3 次提交
    • R
      qemu: install port profile and mac address on netdev hostdevs · ce43483c
      Roopa Prabhu 提交于
      These changes are applied only if the hostdev has a parent net device
      (i.e. if it was defined as "<interface type='hostdev'>" rather than
      just "<hostdev>").  If the parent netdevice has virtual port
      information, the original virtualport associate functions are called
      (these set and restore both mac and port profile on an
      interface). Otherwise, only mac address is set on the device.
      
      Note that This is only supported for SR-IOV Virtual Functions (not for
      standard PCI or USB netdevs), and virtualport association is only
      supported for 802.1Qbh. For all other types of cards and types of
      virtualport, a "Config Unsupported" error is returned and the
      operation fails.
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      ce43483c
    • L
      qemu: support type=hostdev network device live hotplug attach/detach · cf90342b
      Laine Stump 提交于
      qemuDomainAttachNetDevice
      
        - re-ordered some things at start of function because
          networkAllocateActualDevice should always be run and a slot
          in def->nets always allocated, but host_net_add isn't needed
          if the actual type is hostdev.
      
        - if actual type is hostdev, defer to
          qemuDomainAttachHostDevice (which will reach up to the NetDef
          for things like MAC address when necessary). After return
          from qemuDomainAttachHostDevice, slip directly to cleanup,
          since the rest of the function is specific to emulated net
          devices.
      
        - put assignment of new NetDef into expanded def->nets down
          below cleanup: (but only on success) since it is also needed
          for emulated and hostdev net devices.
      
      qemuDomainDetachHostDevice
      
        - after locating the exact device to detach, check if it's a
          network device and, if so, use toplevel
          qemuDomainDetachNetDevice instead so that the def->nets list
          is properly updated, and 'actual device' properly returned to
          network pool if appropriate. Otherwise, for normal hostdevs,
          call the lower level qemuDomainDetachThisDevice.
      
      qemuDomainDetachNetDevice
      
        - This is where it gets a bit tricky. After locating the device
          on the def->nets list, if the network device type == hostdev,
          call the *lower level* qemuDomainDetachThisDevice (which will
          reach back up to the parent net device for MAC address /
          virtualport when appropriate, then clear the device out of
          def->hostdevs) before skipping past all the emulated
          net-device-specific code to cleanup:, where the network
          device is removed from def->nets, and the network device
          object is freed.
      
      In short, any time a hostdev-type network device is detached, we must
      go through the toplevel virDomaineDetachNetDevice function first and
      last, to make sure 1) the def->nnets list is properly managed, and 2)
      any device allocated with networkAllocateActualDevice is properly
      freed. At the same time, in the middle we need to go through the
      lower-level vidDomainDetach*This*HostDevice to be sure that 1) the
      def->hostdevs list is properly managed, 2) the PCI device is properly
      detached from the guest and reattached to the host (if appropriate),
      and 3) any higher level teardown is called at the appropriate time, by
      reaching back up to the NetDef config (part (3) will be covered in a
      separate patch).
      cf90342b
    • L
      qemu: use virDomainNetRemove instead of inline code · 16520d65
      Laine Stump 提交于
      The code being replaced is exactly identical to the newly global
      function, right down to the comment.
      16520d65