1. 09 2月, 2010 6 次提交
  2. 04 2月, 2010 1 次提交
    • D
      Fix restore of QEMU guests with PCI device reservation · 83acdeaf
      Daniel P. Berrange 提交于
      When restoring from a saved guest image, the XML would already
      contain the PCI slot ID of the IDE controller & video card.
      The attempt to explicitly reserve this upfront would thus fail
      everytime.
      
      * src/qemu/qemu_conf.c: Reserve IDE controller / video card
        slot at time of need, rather than upfront
      83acdeaf
  3. 03 2月, 2010 10 次提交
    • D
      Ensure QEMU DAC security driver is activated at all times · 9120f004
      Daniel P. Berrange 提交于
      If the primary security driver (SELinux/AppArmour) was disabled
      then the secondary QEMU DAC security driver was also disabled.
      This is mistaken, because the latter must be active at all times
      
      * src/qemu/qemu_driver.c: Ensure DAC driver is always active
      9120f004
    • D
      Fix QEMU hotplug device alias assignment · 719c50ca
      Daniel P. Berrange 提交于
      To allow devices to be hot(un-)plugged it is neccessary to ensure
      they all have a unique device aliases. This fixes the hotplug
      methods to assign device aliases before invoking the monitor
      commands which need them
      
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Expose methods
        for assigning device aliases for disks, host devices and
        controllers
      * src/qemu/qemu_driver.c: Assign device aliases when hotplugging
        all types of device
      * tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args,
        tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args:
        Update for changed hostdev naming scheme
      719c50ca
    • D
      Disable QEMU monitor IO debugging by default · db0b9e7d
      Daniel P. Berrange 提交于
      db0b9e7d
    • D
      Re-arrange QEMU device alias assignment code · 16478459
      Daniel P. Berrange 提交于
      This patch re-arranges the QEMU device alias assignment code to
      make it easier to call into the same codeblock when performing
      device hotplug. The new code has the ability to skip over already
      assigned names to facilitate hotplug
      
      * src/qemu/qemu_driver.c: Call qemuAssignDeviceNetAlias()
        instead of qemuAssignNetNames
      * src/qemu/qemu_conf.h: Export qemuAssignDeviceNetAlias()
        instead of qemuAssignNetNames
      * src/qemu/qemu_driver.c: Merge the legacy disk/network alias
        assignment code into the main methods
      16478459
    • D
      Remove direct storage of hostnet_name & vlan · 0943048a
      Daniel P. Berrange 提交于
      The current way of assigning names to the host network backend and
      NIC device in QEMU was over complicated, by varying naming scheme
      based on the NIC model and backend type. This simplifies the naming
      to simply be 'net0' and 'hostnet0', allowing code to easily determine
      the host network name and vlan based off the primary device alias
      name 'net0'. This in turn allows removal of alot of QEMU specific
      code from the XML parser, and makes it easier to assign new unique
      names for NICs that are hotplugged
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Remove hostnet_name
        and vlan fields from virNetworkDefPtr
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c:
        Use a single network alias naming scheme regardless of NIC type
        or backend type. Determine VLANs from the alias name.
      * tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args,
        tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.args,
        tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.args: Update
        for new simpler naming scheme
      0943048a
    • D
      Remove use of -netdev arg with QEMU · 49a0f6cd
      Daniel P. Berrange 提交于
      The QEMU 0.12.x tree has the -netdev command line argument, but not
      corresponding monitor command. We can't enable the former, without
      the latter since it will break hotplug/unplug.
      
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Disable -netdev usage
        until 0.13 at earliest
      * tests/qemuxml2argvtest.c: Add test for -netdev syntax
      * tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.args,
        tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.xml: Test
        data files for -netdev syntax
      49a0f6cd
    • D
      Assign PCI addresses before hotplugging devices · d8acc446
      Daniel P. Berrange 提交于
      PCI disk, disk controllers, net devices and host devices need to
      have PCI addresses assigned before they are hot-plugged
      
      * src/qemu/qemu_conf.c: Add APIs for ensuring a device has an
        address and releasing unused addresses
      * src/qemu/qemu_driver.c: Ensure all devices have addresses
        when hotplugging.
      d8acc446
    • D
      Rewrite way QEMU PCI addresses are allocated · 9258ec0a
      Daniel P. Berrange 提交于
      The current QEMU code allocates PCI addresses incrementally starting
      at 4. This is not satisfactory because the user may have given some
      addresses in their XML config, which need to be skipped over when
      allocating addresses to remaining devices.
      
      It is thus neccessary to maintain a list of already allocated PCI
      addresses and then only allocate ones that remain unused. This is
      also required for domain device hotplug to work properly later.
      
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add APIs for creating
        list of existing PCI addresses, and allocating new addresses.
        Refactor address assignment to use this code
      * src/qemu/qemu_driver.c: Pull PCI address assignment up into the
        qemuStartVMDaemon() method, as a prelude to moving it into the
        'define' method. Update list of allocated addresses when connecting
        to a running VM at daemon startup.
      * tests/qemuxml2argvtest.c, tests/qemuargv2xmltest.c,
        tests/qemuxml2xmltest.c: Remove USB product test since all
        passthrough is done based on address
      * tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args,
        tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml: Kil
        unused data files
      9258ec0a
    • D
      Make hotplug use new device_add where possible · 264e98d6
      Daniel P. Berrange 提交于
      Since QEMU startup uses the new -device argument, the hotplug
      code needs todo the same. This converts disk, network and
      host device hotplug to use the device_add command
      
      * src/qemu/qemu_driver.c: Use new device_add monitor APIs
        whereever possible
      264e98d6
    • D
      Introduce internal QEMU monitor APIs for drive + device hotadd · 5ec6cf7f
      Daniel P. Berrange 提交于
      The way QEMU is started has been changed to use '-device' and
      the new style '-drive' syntax. This needs to be mirrored in
      the hotplug code, requiring addition of two new APIs.
      
      * src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Define APIs
        qemuMonitorAddDevice() and qemuMonitorAddDrive()
      * src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
        src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
        Implement the new monitor APIs
      5ec6cf7f
  4. 02 2月, 2010 4 次提交
    • D
      Split out QEMU code for building PCI/USB hostdev arg values · 96c8608d
      Daniel P. Berrange 提交于
      To allow for better code reuse from hotplug methods, the code for
      generating PCI/USB hostdev arg values is split out into separate
      methods
      
      * qemu/qemu_conf.h, qemu/qemu_conf.c: Introduce new APis for
        qemuBuildPCIHostdevPCIDevStr, qemuBuildUSBHostdevUsbDevStr
        and qemuBuildUSBHostdevDevStr
      96c8608d
    • D
      Standard internal API syntax for building QEMU command line arguments · c129d4fe
      Daniel P. Berrange 提交于
      All the helper functions for building command line arguments
      now return a 'char *', instead of acepting a 'char **' or
      virBufferPtr argument
      
      * qemu/qemu_conf.c: Standardize syntax for building args
      * qemu/qemu_conf.h: Export all functions for building args
      * qemu/qemu_driver.c: Update for changed syntax for building
        NIC/hostnet args
      c129d4fe
    • J
      avoid a probable EINVAL from lseek · 9344e6ad
      Jim Meyering 提交于
      * src/qemu/qemu_driver.c (qemudLogReadFD): Don't pass a negative
      offset (from a preceding failed attempt to seek to EOF) to this use
      of lseek.
      9344e6ad
    • J
      avoid format-related warnings · 4cd188d4
      Jim Meyering 提交于
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextGetAllPCIAddresses):
      Use %s.
      * src/storage/storage_backend_iscsi.c (virStorageBackendCreateIfaceIQN):
      Likewise.
      * tools/virsh.c (cmdSecretSetValue): Likewise.
      4cd188d4
  5. 01 2月, 2010 3 次提交
    • C
      Fix PCI host reattach on domain detach. · 29727bac
      Chris Lalancette 提交于
      Similar to the race fixed by
      be34c3c7, make sure
      to wait around for KVM to release the resources from
      a hot-detached PCI device before attempting to
      rebind that device to the host driver.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      29727bac
    • M
      Clarify controllers -device string in QEMU driver · 09080c38
      Matthew Booth 提交于
      The QEMU driver contained code to generate a -device string for piix4-ide, but
      wasn't using it. This change removes this string generation. It also adds a
      comment explaining why IDE and FDC controllers don't generate -device strings.
      
      The change also generates an error if a sata controller is specified for a QEMU
      domain, as this isn't supported.
      
      * src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
        qemuBuildControllerDevStr(). Ignore IDE and FDC controllers. Error if
        SATA controller is discovered. Add comments.
      09080c38
    • C
      Look in /usr/libexec for the qemu-kvm binary. · b16cd226
      Chris Lalancette 提交于
      On RHEL-5 the qemu-kvm binary is located in /usr/libexec.
      To reduce confusion for people trying to run upstream libvirt
      on RHEL-5 machines, make the qemu driver look in /usr/libexec
      for the qemu-kvm binary.
      
      To make this work, I modified virFindFileInPath to handle an
      absolute path correctly.  I also ran into an issue where
      NULL was sometimes being passed for the file parameter
      to virFindFileInPath; it didn't crash prior to this patch
      since it was building paths like /usr/bin/(null).  This
      is non-standard behavior, though, so I added a NULL
      check at the beginning.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      b16cd226
  6. 26 1月, 2010 6 次提交
    • C
      Fix a crash when restarting libvirtd. · 7cc5410b
      Chris Lalancette 提交于
      If you shutdown libvirtd while a domain with PCI
      devices is running, then try to restart libvirtd,
      libvirtd will crash.
      
      This happens because qemuUpdateActivePciHostdevs() is calling
      pciDeviceListSteal() with a dev of 0x0 (NULL), and then trying
      to dereference it.  This patch fixes it up so that
      qemuUpdateActivePciHostdevs() steals the devices after first
      Get()'ting them, avoiding the crash.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      7cc5410b
    • J
      qemuMonitorTextAttachDrive: avoid two leaks · 1af75828
      Jim Meyering 提交于
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextAttachDrive): Most other
      failures in this function would "goto cleanup", but one mistakenly
      returned directly, skipping the cleanup and resulting in a leak.
      In addition, iterating the "try_command" loop would clobber, and
      thus leak, the "cmd" allocated on the first iteration,
      so be careful to free it in addition to "reply" beforehand.
      1af75828
    • M
      731c7386
    • D
      Implement QMP support for extracting CPU thread ID · 72a8405a
      Daniel P. Berrange 提交于
      The KVM build of QEMU includs the thread ID of each vCPU in the
      'query-cpus' output. This is required for pinning guests to
      particular host CPUs
      
      * src/qemu/qemu_monitor_json.c: Extract 'thread_id' from CPU info
      72a8405a
    • D
      Misc fixes to QMP monitor support for QEMU · 2c7f5ca6
      Daniel P. Berrange 提交于
      * src/util/json.c, src/util/json.h: Declare returned strings
        to be const
      * src/qemu/qemu_monitor.c: Wire up JSON mode for qemuMonitorGetPtyPaths
      * src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Fix
        const correctness. Add missing error message in the function
        qemuMonitorJSONGetAllPCIAddresses. Add implementation of the
        qemuMonitorGetPtyPaths function calling 'query-chardev'.
      2c7f5ca6
    • J
      qemuMonitorTextGetMemoryStats: plug a leak on an error path · 9827e0a4
      Jim Meyering 提交于
      * src/qemu/qemu_monitor_text.c (qemuMonitorCommandWithHandler):
      Always free *reply, upon failure.
      9827e0a4
  7. 23 1月, 2010 1 次提交
    • C
      qemu: Fix race between device rebind and kvm cleanup · be34c3c7
      Chris Lalancette 提交于
      Certain hypervisors (like qemu/kvm) map the PCI bar(s) on
      the host when doing device passthrough.  This can lead to a race
      condition where the hypervisor is still cleaning up the device while
      libvirt is trying to re-attach it to the host device driver.  To avoid
      this situation, we look through /proc/iomem, and if the hypervisor is
      still holding onto the bar (denoted by the string in the matcher variable),
      then we can wait around a bit for that to clear up.
      
      v2: Thanks to review by DV, make sure we wait the full timeout per-device
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      be34c3c7
  8. 22 1月, 2010 1 次提交
  9. 21 1月, 2010 8 次提交
    • A
      domMemoryStats / qemu: Fix parsing of unknown stats · 80b4d20d
      Adam Litke 提交于
      Fix a small problem with the qemu memory stats parsing algorithm.  If qemu
      reports a stat that libvirt does not recognize, skip past it so parsing can
      continue.  This corrects a potential infinite loop in the parsing code that can
      only be triggered if new statistics are added to qemu.
      
      * src/qemu/qemu_monitor_text.c: qemuMonitorParseExtraBalloonInfo add a
        skip for extra ','
      80b4d20d
    • J
      avoid more format-related warnings · d47b6e54
      Jim Meyering 提交于
      * src/qemu/qemu_conf.c (qemuBuildDriveStr): Use "%s".
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetGuestPCIAddress):
      (qemuMonitorJSONGetGuestDriveAddress): Likewise.
      d47b6e54
    • D
      Fix off-by-1 in SCSI drive hotplug · 6512d09c
      Daniel P. Berrange 提交于
      The loop looking for the controller associated with a SCI drive had
      an off by one, causing it to miss the last controller.
      
      * src/qemu/qemu_driver.c: Fix off-by-1 in searching for SCSI
        drive hotplug
      6512d09c
    • D
      Fix leak in hotplug code in QEMU driver · e3a0c80f
      Daniel P. Berrange 提交于
      The hotplug code in QEMU was leaking memory because although the
      inner device object was being moved into the main virDomainDefPtr
      config object, the outer container virDomainDeviceDefPtr was not.
      
       * src/qemu/qemu_driver.c: Clarify code to show that the inner
         device object is owned by the main domain config upon
         successfull attach.
      e3a0c80f
    • D
      Add configuration option to turn off dynamic permissions management · 5b6782f9
      Daniel P. Berrange 提交于
      Add the ability to turn off dynamic management of file permissions
      for libvirt guests.
      
      * qemu/libvirtd_qemu.aug: Support 'dynamic_ownership' flag
      * qemu/qemu.conf: Document 'dynamic_ownership' flag.
      * qemu/qemu_conf.c: Load 'dynamic_ownership' flag
      * qemu/test_libvirtd_qemu.aug: Test 'dynamic_ownership' flag
      5b6782f9
    • D
      Fix security driver calls in hotplug cleanup paths · 2df16576
      Daniel P. Berrange 提交于
      The hotplug code was not correctly invoking the security driver
      in error paths. If a hotplug attempt failed, the device would
      be left with VM permissions applied, rather than restored to the
      original permissions. Also, a CDROM media that is ejected was
      not restored to original permissions. Finally there was a bogus
      call to set hostdev permissions in the hostdev unplug code
      
      * qemu/qemu_driver.c: Fix security driver usage in hotplug/unplug
      2df16576
    • D
      Add missing call to re-attach host devices if VM startup fails · b2a2ba71
      Daniel P. Berrange 提交于
      If there is a problem with VM startup, PCI devices may be left
      assigned to pci-stub / pci-back. Adding a call to reattach
      host devices in the cleanup path is required.
      
      * qemu/qemu_driver.c: qemuDomainReAttachHostDevices() when
        VM startup fails
      b2a2ba71
    • D
      Switch QEMU driver over to use the DAC security driver · 3812c7b4
      Daniel P. Berrange 提交于
      Remove all the QEMU driver calls for setting file ownership and
      process uid/gid. Instead wire in the QEMU DAC security driver,
      stacking it ontop of the primary SELinux/AppArmour driver.
      
      * qemu/qemu_driver.c: Switch over to new DAC security driver
      3812c7b4