1. 06 3月, 2010 2 次提交
    • J
      qemudDomainAttachSCSIDisk: handle empty controller list · f5a6ce44
      Jim Meyering 提交于
      * src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk): Handle
      the (theoretical) case of an empty controller list, so that
      clang does not think the subsequent dereference of "cont"
      would dereference an undefined variable (due to preceding
      loop not iterating even once).
      f5a6ce44
    • J
      qemu restore: don't let corrupt input provoke unwarranted OOM · 1a4d5c95
      Jim Meyering 提交于
      * src/qemu/qemu_driver.c (qemudDomainRestore): A corrupt save file
      (in particular, a too-large header.xml_len value) would cause an
      unwarranted out-of-memory error.  Do not trust the just-read
      header.xml_len.  Instead, merely use that as a hint, and
      read/allocate up to that number of bytes from the file.
      Also verify that header.xml_len is positive; if it were negative,
      passing it to virFileReadLimFD could cause trouble.
      1a4d5c95
  2. 05 3月, 2010 3 次提交
    • D
      Fix USB passthrough based on product/vendor · 09ed0729
      Daniel P. Berrange 提交于
      Changeset
      
        commit 5073aa99
        Author: Cole Robinson <crobinso@redhat.com>
        Date:   Mon Jan 11 11:40:46 2010 -0500
      
      Added support for product/vendor based passthrough, but it only
      worked at the security driver layer. The main guest XML config
      was not updated with the resolved bus/device ID. When the QEMU
      argv refactoring removed use of product/vendor, this then broke
      launching guests.
      
      THe solution is to move the product/vendor resolution up a layer
      into the QEMU driver. So the first thing QEMU does is resolve
      the product/vendor to a bus/device and updates the XML config
      with this info. The rest of the code, including security drivers
      and QEMU argv generated can now rely on bus/device always being
      set.
      
      * src/util/hostusb.c, src/util/hostusb.h: Split vendor/product
        resolution code out of usbGetDevice and into usbFindDevice.
        Add accessors for bus/device ID
      * src/security/virt-aa-helper.c, src/security/security_selinux.c,
        src/qemu/qemu_security_dac.c: Remove vendor/product from the
        usbGetDevice() calls
      * src/qemu/qemu_driver.c: Use usbFindDevice to resolve vendor/product
        into a bus/device ID
      09ed0729
    • D
      Convert QEMU driver all hotunplug code from pci_del to device_del · 84a25570
      Daniel P. Berrange 提交于
      The pci_del command is not being ported to QMP. Convert all the
      QEMU hotplug code over to use device_del whenever it is available
      to avoid the pci_del problem
      
      * src/qemu/qemu_driver.c: Convert unplug code to device_del
      84a25570
    • D
      Support hot-unplug for USB devices in QEMU · 8c82479d
      Daniel P. Berrange 提交于
      Previously hot-unplug could not be supported for USB devices
      in QEMU, since usb_del required the guest visible address
      which libvirt never knows. With 'device_del' command we can
      now unplug based on device alias, so support that.
      
      * src/qemu/qemu_driver.c: Use device_del to remove USB devices
      8c82479d
  3. 04 3月, 2010 5 次提交
    • D
      Support VCPU hotplug in QEMU guests · e8d6c289
      Daniel P. Berrange 提交于
      QEMU has a monitor command 'set_cpu' which allows a specific
      CPU to be toggled between online& offline state. libvirt CPU
      hotplug does not work in terms of individual indexes CPUs.
      Thus to support this, we iteratively toggle the online state
      when the total number of vCPUs is adjusted via libvirt
      
      NB, currently untested since QEMU segvs when running this!
      
      * src/qemu/qemu_driver.c: Toggle online state for CPUs when
        doing hotplug
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
        src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
        src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
        monitor API for toggling a CPU's online status via 'set_cpu
      e8d6c289
    • D
      Don't raise error message from cgroups if QEMU fails to start · b50d48b1
      Daniel P. Berrange 提交于
      The code to remove the cgroup after QEMU failed to startup could
      be obscuring a real error from earlier on. It is not neccessary
      to raise an error in this case, so tell cgroups to keep quiet
      
      * src/qemu/qemu_driver.c: Don't raise cgroups error in QEMU start
        cleanup code.
      b50d48b1
    • D
      Add missing device type check in QEMU PCI hotunplug · badfe6c7
      Daniel P. Berrange 提交于
      The QEMU hotunplug code for PCI devices was looking at host
      devices in the guest config without first filtering non
      PCI devices. This means it was reading garbage
      
      * src/qemu/qemu_driver.c: Filter out non-PCI devices
      badfe6c7
    • C
      Add a define for NFS_SUPER_MAGIC · 6ef5a5be
      Chris Lalancette 提交于
      Commit 3c12a67b added
      a dependency on the NFS_SUPER_MAGIC macro, which is
      defined in linux/magic.h.  Unfortunately linux/magic.h
      is not available in RHEL-5, and causes a compile error.
      Just define it locally, since this is something that
      can't change.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      6ef5a5be
    • L
      Make domain save work on root-squash NFS · 3c12a67b
      Laine Stump 提交于
      Move *all* file operations related to creation and writing of libvirt
      header to the domain save file into a hook function that is called by
      virFileOperation. First try to call virFileOperation as root. If that
      fails with EACCESS, and (in the case of Linux) statfs says that we're
      trying to save the file on an NFS share, rerun virFileOperation,
      telling it to fork a child process and setuid to the qemu user. This
      is the only way we can successfully create a file on a root-squashed
      NFS server.
      
      This patch (along with setting dynamic_ownership=0 in qemu.conf)
      makes qemudDomainSave work on root-squashed NFS.
      
      * src/qemu/qemu_driver.c: provide new qemudDomainSaveFileOpHook()
        utility, use it in qemudDomainSave() if normal creation of the
        file as root failed, and after checking the filesystem type for
        the storage is NFS. In that case we also bypass the security
        driver, as this would fail on NFS.
      3c12a67b
  4. 03 3月, 2010 7 次提交
    • L
      Fix domain restore for files on root-squash NFS · a03121bc
      Laine Stump 提交于
      If qemudDomainRestore fails to open the domain save file, create a
      pipe, then fork a process that does setuid(qemu_user) and opens the
      file, then reads this file and stuffs it into the pipe. the parent
      libvirtd process will use the other end of the pipe as its fd, then
      reap the child process after it's done reading.
      
      This makes domain restore work on a root-squash NFS share that is only
      visible to the qemu user.
      
      * src/qemu/qemu_driver.c: add new qemudOpenAsUID() helper function,
        and use it in qemudDomainRestore() if reading as root directly failed.
      a03121bc
    • D
      Fix USB/PCI device address aliases in QEMU hotplug driver · 9882123d
      Daniel P. Berrange 提交于
      The USB/PCI device hotplug code for the QEMU driver was forgetting
      to allocate a unique device alias.
      
      * src/qemu/qemu_driver.c: Fill in device alias for USB/PCI devices
      9882123d
    • D
      Fix QEMU domain state after a save attempt fails · cf104533
      Daniel P. Berrange 提交于
      When a VM save attempt failed, the VM would be left in a paused
      state. It is neccessary to resume CPU execution upon failure
      if it was running originally
      
      * src/qemu/qemu_driver.c: Resume CPUs upon save failure
      cf104533
    • D
      Support job cancellation in QEMU driver · 04c7abd9
      Daniel P. Berrange 提交于
      This supports cancellation of jobs for the QEMU driver against
      the virDomainMigrate, virDomainSave and virDomainCoreDump APIs.
      It is not yet supported for the virDomainRestore API, although
      it is desirable.
      
      * src/qemu/qemu_driver.c: Issue 'migrate_cancel' command if
        virDomainAbortJob is issued during a migration operation
      * tools/virsh.c: Add a domjobabort command
      04c7abd9
    • D
      Wire up internal entry points for virDomainAbortJob API · 0d8aa35f
      Daniel P. Berrange 提交于
      This provides the internal glue for the driver API
      
      * src/driver.h: Internal API contract
      * src/libvirt.c, src/libvirt_public.syms: Connect public API
        to driver API
      * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
        src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
        src/qemu/qemu_driver.c, src/remote/remote_driver.c,
        src/test/test_driver.c src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
        src/xen/xen_driver.c: Stub out entry points
      0d8aa35f
    • D
      Add QEMU driver support for job info on migration ops · 0d3eee7f
      Daniel P. Berrange 提交于
      Introduce support for  virDomainGetJobInfo in the QEMU driver. This
      allows for monitoring of any API that uses the 'info migrate' monitor
      command. ie virDomainMigrate, virDomainSave and virDomainCoreDump
      
      Unfortunately QEMU does not provide a way to monitor incoming migration
      so we can't wire up virDomainRestore yet.
      
      The virsh tool gets a new command 'domjobinfo' to query status
      
      * src/qemu/qemu_driver.c: Record virDomainJobInfo and start time
        in qemuDomainObjPrivatePtr objects. Add generic shared handler
        for calling 'info migrate' with all migration based APIs.
      * src/qemu/qemu_monitor_text.c: Fix parsing of 'info migration' reply
      * tools/virsh.c: add new 'domjobinfo' command to query progress
      0d3eee7f
    • D
      Stub out internal driver entry points for job processing · 92bd859a
      Daniel P. Berrange 提交于
      The internal glue layer for the new pubic API
      
      * src/driver.h: Define internal driver API contract
      * src/libvirt.c, src/libvirt_public.syms: Wire up public
        API to internal driver API
      * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
        src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
        src/qemu/qemu_driver.c, src/remote/remote_driver.c,
        src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
        src/xen/xen_driver.c: Stub new entry point
      92bd859a
  5. 02 3月, 2010 5 次提交
    • R
      Fix USB hotplug device string in QEMU driver · 06973f70
      Rolf Eike Beer 提交于
      The USB hotplug method was mistakenly generating a PCI address
      string
      
      * src/qemu/qemu_driver.c: Fix USB hotplug device string
      06973f70
    • W
      Use device_del to remove SCSI controllers · 8540dadb
      Wolfgang Mauerer 提交于
      when the underlying qemu supports the drive/device model and the
      controller has been added this way.
      * src/qemu/qemu_driver.c: use qemuMonitorDelDevice() when detaching
        PCI controller and if supported
      * src/qemu/qemu_monitor.[ch]: add new qemuMonitorDelDevice() function
      * src/qemu/qemu_monitor_json.[ch]: JSON backend for DelDevice command
      * src/qemu/qemu_monitor_text.[ch]: Text backend for DelDevice command
      8540dadb
    • W
      Fix PCI address handling when controllers are deleted · 55946f23
      Wolfgang Mauerer 提交于
      * src/qemu/qemu_driver.c: in qemudDomainDetachPciControllerDevice()
        when a controller is not present in the system anymore, the PCI
        address must be deleted from libvirt's hashtable because it can
        be re-used for other purposes.
      55946f23
    • W
      Fix data structure handling when controllers are attached · 24cc058e
      Wolfgang Mauerer 提交于
      * src/qemu/qemu_driver.c: in qemudDomainAttachDevice(), one must not
        delete the data part when the operation succeeds because it is
        required later on. The correct pattern to handlethe parsed
        representation of the device information on success
        is dev->data.controller = NULL; virDomainDeviceDefFree(dev);,
        which leaves the structure pointed at by data in memory.
      24cc058e
    • W
      Tiny spelling fix · 553447ac
      Wolfgang Mauerer 提交于
      553447ac
  6. 19 2月, 2010 3 次提交
    • C
      Better error reporting for failed migration · b97c24b2
      Chris Lalancette 提交于
      If the hostname as returned by "gethostname" resolves
      to "localhost" (as it does with the broken Fedora-12
      installer), then live migration will fail because the
      source will try to migrate to itself.  Detect this
      situation up-front and abort the live migration before
      we do any real work.
      
      * src/util/util.h src/util/util.c: add a new virGetHostnameLocalhost
        with an optional localhost check, and rewire virGetHostname() to use
        it
      * src/libvirt_private.syms: expose the new function
      * src/qemu/qemu_driver.c: use it in qemudDomainMigratePrepare2()
      b97c24b2
    • S
      macvtap mac_filter support · b3e7890a
      Stefan Berger 提交于
      This patch adds the mac_filter support to the macvtap device.
      b3e7890a
    • S
      macvtap IFF_VNET_HDR configuration · e52687e8
      Stefan Berger 提交于
      This patch sets or unsets the IFF_VNET_HDR flag depending on what device
      is used in the VM. The manipulation of the flag is done in the open
      function and is only fatal if the IFF_VNET_HDR flag could not be cleared
      although it has to be (or if an ioctl generally fails). In that case the
      macvtap tap is closed again and the macvtap interface torn.
      
      * src/qemu/qemu_conf.c src/qemu/qemu_conf.h: pass qemuCmdFlags to
        qemudPhysIfaceConnect()
      * src/util/macvtap.c src/util/macvtap.h: add vnet_hdr boolean to
        openMacvtapTap(), and private function configMacvtapTap()
      * src/qemu/qemu_driver.c: add extra qemuCmdFlags when calling
        qemudPhysIfaceConnect()
      e52687e8
  7. 18 2月, 2010 2 次提交
    • M
      Fix typo in comment · 27e63c00
      Matthew Booth 提交于
      * src/qemu/qemu_driver.c: qemudStartVMDaemon() fix typo in comment
      27e63c00
    • S
      macvtap teardown rework · f162252e
      Stefan Berger 提交于
      Rework and simplification of teardown of the macvtap device.
      
      Basically all devices with the same MAC address and link device are kept
      alive and not attempted to be torn down. If a macvtap device linked to a
      physical interface with a certain MAC address 'M' is to be created it
      will automatically fail if the interface is 'up'ed and another macvtap
      with the same properties (MAC addr 'M', link dev) happens to be 'up'.
      This will prevent the VM from starting or the device from being attached
      to a running VM. Stale interfaces are assumed to be there for some
      reason and not stem from libvirt.
      
      In the VM shutdown path, it's assuming that an interface name is always
      available so that if the device type is DIRECT it can be torn down
      using its name.
      
      * src/util/macvtap.h src/libvirt_macvtap.syms: change of deleting routine
      * src/util/macvtap.c: cleanups and change of deleting routine
      * src/qemu/qemu_driver.c: change cleanup on shutdown
      * src/qemu/qemu_conf.c: don't delete Macvtap in qemudPhysIfaceConnect()
      f162252e
  8. 17 2月, 2010 3 次提交
    • J
      qemuInitPasswords: avoid unconditional leak · 309647c8
      Jim Meyering 提交于
      * src/qemu/qemu_driver.c (qemuInitPasswords): Free pass-phrase buffer.
      309647c8
    • C
      qemu: Make SetVcpu command hotplug only · 8c38b5dc
      Cole Robinson 提交于
      Similar to the Set*Mem commands, this implementation was bogus and
      misleading. Make it clear this is a hotplug only operation, and that the
      hotplug piece isn't even implemented.
      
      Also drop the overkill maxvcpus validation: we don't perform this check
      at XML define time so clearly no one is missing it, and there is
      always the risk that our info will be out of date, possibly preventing
      legitimate CPU values.
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      8c38b5dc
    • C
      qemu: Make Set*Mem commands hotplug only · 09a33fd8
      Cole Robinson 提交于
      SetMem and SetMaxMem are hotplug only APIs, any persistent config
      changes are supposed to go via XML definition. The original implementation
      of these calls were incorrect and had the nasty side effect of making
      a psuedo persistent change that would be lost after libvirtd restart
      (I didn't know any better).
      
      Fix these APIs to rightly reject non running domains.
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      09a33fd8
  9. 16 2月, 2010 2 次提交
    • D
      Run 'qmp_capabilities' command at QEMU monitor startup · 5d72a894
      Daniel P. Berrange 提交于
      When in JSON mode, QEMU requires that 'qmp_capabilities' is run as
      the first command in the monitor. This is a no-op when run in the
      text mode monitor
      
      * src/qemu/qemu_driver.c: Run capabilities negotiation when
        connecting to the monitor
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
        src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Add
        support for the 'qmp_capabilities' command, no-op in text mode.
      5d72a894
    • S
      macvtap support for libvirt -- qemu support · a1b1ab14
      Stefan Berger 提交于
      This part adds support for qemu making a macvtap tap device available
      via file descriptor passed to qemu command line. This also attempts to
      tear down the macvtap device when a VM terminates. This includes support
      for attachment and detachment to/from running VM.
      * src/qemu/qemu_conf.[ch] src/qemu/qemu_driver.c: add support in the
        QEmu driver
      a1b1ab14
  10. 13 2月, 2010 2 次提交
    • D
      Add persistence of PCI addresses to QEMU · 141dea6b
      Daniel P. Berrange 提交于
      Current PCI addresses are allocated at time of VM startup.
      To make them truely persistent, it is neccessary to do this
      at time of virDomainDefine/virDomainCreate. The code in
      qemuStartVMDaemon still remains in order to cope with upgrades
      from older libvirt releases
      
      * src/qemu/qemu_driver.c: Rename existing qemuAssignPCIAddresses
        to qemuDetectPCIAddresses. Add new qemuAssignPCIAddresses which
        does auto-allocation upfront. Call qemuAssignPCIAddresses from
        qemuDomainDefine and qemuDomainCreate to assign PCI addresses that
        can then be persisted. Don't clear PCI addresses at shutdown if
        they are intended to be persistent
      141dea6b
    • D
      Support 'block_passwd' command for QEMU disk encryption · c31a116b
      Daniel P. Berrange 提交于
      The old text mode monitor prompts for a password when disks are
      encrypted. This interactive approach doesn't work for JSON mode
      monitor. Thus there is a new 'block_passwd' command that can be
      used.
      
      * src/qemu/qemu_driver.c: Split out code for looking up a disk
        secret from findVolumeQcowPassphrase, into a new method
        getVolumeQcowPassphrase. Enhance qemuInitPasswords() to also
        set the disk encryption password via the monitor
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
        src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
        src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
        support for the 'block_passwd' monitor command.
      c31a116b
  11. 12 2月, 2010 3 次提交
  12. 10 2月, 2010 3 次提交
    • C
      qemu: Increase guest startup timeout to 30 seconds · d3024a2c
      Cole Robinson 提交于
      Currently the timeout for reading startup output is 3 seconds. If the
      host is under any sort of load, we can easily trigger this. Lets bump
      it to 30 seconds.
      
      Since the polling loop checks to see if the process has died, we shouldn't
      erroneously hit this timeout if qemu bombs (only if it is stuck in some
      infinite loop).
      d3024a2c
    • C
      qemu: Properly report a startup timeout error · b65490a3
      Cole Robinson 提交于
      The timeout errors were unconditionally being overwritten by the less
      helpful 'unable to start guest' error.
      b65490a3
    • D
      Remove virConnectPtr from CPU XML APIs · f430ddb6
      Daniel P. Berrange 提交于
      The virConnectPtr is no longer required for error reporting since
      that is recorded in a thread local. Remove use of virConnectPtr
      from all APIs in cpu_conf.{h,c} and update all callers to
      match
      f430ddb6