1. 15 10月, 2010 1 次提交
  2. 14 10月, 2010 1 次提交
  3. 13 10月, 2010 6 次提交
    • S
      nwfilter: resolve deadlock between VM ops and filter update · 4435f3c4
      Stefan Berger 提交于
       This is from a bug report and conversation on IRC where Soren reported that while a filter update is occurring on one or more VMs (due to a rule having been edited for example), a deadlock can occur when a VM referencing a filter is started.
      
      The problem is caused by the two locking sequences of
      
      qemu driver, qemu domain, filter             # for the VM start operation
      filter, qemu_driver, qemu_domain            # for the filter update operation
      
      that obviously don't lock in the same order. The problem is the 2nd lock sequence. Here the qemu_driver lock is being grabbed in qemu_driver:qemudVMFilterRebuild()
      
      The following solution is based on the idea of trying to re-arrange the 2nd sequence of locks as follows:
      
      qemu_driver, filter, qemu_driver, qemu_domain
      
      and making the qemu driver recursively lockable so that a second lock can occur, this would then lead to the following net-locking sequence
      
      qemu_driver, filter, qemu_domain
      
      where the 2nd qemu_driver lock has been ( logically ) eliminated.
      
      The 2nd part of the idea is that the sequence of locks (filter, qemu_domain) and (qemu_domain, filter) becomes interchangeable if all code paths where filter AND qemu_domain are locked have a preceding qemu_domain lock that basically blocks their concurrent execution
      
      So, the following code paths exist towards qemu_driver:qemudVMFilterRebuild where we now want to put a qemu_driver lock in front of the filter lock.
      
      -> nwfilterUndefine()   [ locks the filter ]
          -> virNWFilterTestUnassignDef()
              -> virNWFilterTriggerVMFilterRebuild()
                  -> qemudVMFilterRebuild()
      
      -> nwfilterDefine()
          -> virNWFilterPoolAssignDef() [ locks the filter ]
              -> virNWFilterTriggerVMFilterRebuild()
                  -> qemudVMFilterRebuild()
      
      -> nwfilterDriverReload()
          -> virNWFilterPoolLoadAllConfigs()
              ->virNWFilterPoolObjLoad()
                  -> virNWFilterPoolAssignDef() [ locks the filter ]
                      -> virNWFilterTriggerVMFilterRebuild()
                          -> qemudVMFilterRebuild()
      
      -> nwfilterDriverStartup()
          -> virNWFilterPoolLoadAllConfigs()
              ->virNWFilterPoolObjLoad()
                  -> virNWFilterPoolAssignDef() [ locks the filter ]
                      -> virNWFilterTriggerVMFilterRebuild()
                          -> qemudVMFilterRebuild()
      
      Qemu is not the only driver using the nwfilter driver, but also the UML driver calls into it. Therefore qemuVMFilterRebuild() can be exchanged with umlVMFilterRebuild() along with the driver lock of qemu_driver that can now be a uml_driver. Further, since UML and Qemu domains can be running on the same machine, the triggering of a rebuild of the filter can touch both types of drivers and their domains.
      
      In the patch below I am now extending each nwfilter callback driver with functions for locking and unlocking the (VM) driver (UML, QEMU) and introduce new functions for locking all registered callback drivers and unlocking them. Then I am distributing the lock-all-cbdrivers/unlock-all-cbdrivers call into the above call paths. The last shown callpath starting with nwfilterDriverStart() is problematic since it is initialize before the Qemu and UML drives are and thus a lock in the path would result in a NULL pointer attempted to be locked -- the call to virNWFilterTriggerVMFilterRebuild() is never called, so we never lock either the qemu_driver or the uml_driver in that path. Therefore, only the first 3 paths now receive calls to lock and unlock all callback drivers. Now that the locks are distributed where it matters I can remove the qemu_driver and uml_driver lock from qemudVMFilterRebuild() and umlVMFilterRebuild() and not requiring the recursive locks.
      
      For now I want to put this out as an RFC patch. I have tested it by 'stretching' the critical section after the define/undefine functions each lock the filter so I can (easily) concurrently execute another VM operation (suspend,start). That code is in this patch and if you want you can de-activate it. It seems to work ok and operations are being blocked while the update is being done.
      I still also want to verify the other assumption above that locking filter and qemu_domain always has a preceding qemu_driver lock.
      4435f3c4
    • N
      Adding memtunables to qemuSetupCgroup · 261ad74e
      Nikunj A. Dadhania 提交于
      QEmu startup will pick up the memory tunables specified in the domain
      configuration file
      261ad74e
    • N
      Implement domainGetMemoryParamters for QEmu · 013fe4b8
      Nikunj A. Dadhania 提交于
      Driver interface for getting memory parameters, eg. hard_limit,
      soft_limit and swap_hard_limit based on cgroup support
      013fe4b8
    • N
      Implement domainSetMemoryParamters for QEmu · 71d0b427
      Nikunj A. Dadhania 提交于
      Driver interface for setting memory hard_limit, soft_limit and swap
      hard_limit based on cgroup support
      71d0b427
    • N
      XML parsing for memory tunables · d390fce4
      Nikunj A. Dadhania 提交于
      Adding parsing code for memory tunables in the domain xml file
      also change the internal define structures used for domain memory
      informations
      Adds a new specific test
      d390fce4
    • N
      Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API · 0cd78232
      Nikunj A. Dadhania 提交于
      Public api to set/get memory tunables supported by the hypervisors.
      
      dv:
      * some cleanups in libvirt.c
      * adding extra checks in libvirt.c new entry points
      
      v4:
      * Move exporting public API to this patch
      * Add unsigned int flags to the public api for future extensions
      
      v3:
      * Add domainGetMemoryParamters and NULL in all the driver interface
      
      v2:
      * Initialize domainSetMemoryParameters to NULL in all the driver
        interface structure.
      0cd78232
  4. 25 8月, 2010 1 次提交
  5. 20 8月, 2010 1 次提交
    • E
      build: delete dead comments · 4b930023
      Eric Blake 提交于
      * src/qemu/qemu_driver.c (qemudGetProcessInfo): Clean up.
      * src/uml/uml_driver.c (umlGetProcessInfo): Likewise.
      * src/xen/sexpr.c (_string2sexpr): Likewise.
      4b930023
  6. 18 8月, 2010 1 次提交
    • C
      Fix up qemu domain save/managed save locking. · 4303c91c
      Chris Lalancette 提交于
      The current version of the qemu managed save implementation
      is subject to a race where the domain shuts down between
      the time that we start the command and the time that we
      actually try to do the save.  Close this race by making
      qemuDomainSaveFlags() expect both the driver and the passed-in
      vm object to be locked before executing.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      4303c91c
  7. 17 8月, 2010 4 次提交
    • J
      qemu: Fix copy&paste error in warning message · 0a5f3ae0
      Jiri Denemark 提交于
      This also makes the message consistent with the message used in error
      path of qemudDomainAttachHostPciDevice.
      0a5f3ae0
    • J
      5afec517
    • J
      qemu: Re-reserve all PCI addresses on libvirtd restart · 4f86613b
      Jiri Denemark 提交于
      When reconnecting to existing VMs, we re-reserved only those PCI
      addresses which were explicitly mentioned in domain XML. Since some
      addresses are always reserved (e.g., 0:0:0 and 0:0:1), we need to handle
      those too.
      
      Also all this should only be done if device flag is supported by qemu.
      4f86613b
    • S
      nwfilter: extend nwfilter reload support · cf6f8b9a
      Stefan Berger 提交于
      In this patch I am extending and fixing the nwfilter module's reload support to stop all ongoing threads (for learning IP addresses of interfaces) and rebuild the filtering rules of all interfaces of all VMs when libvirt is started. Now libvirtd rebuilds the filters upon the SIGHUP signal and libvirtd restart.
      
      About the patch: The nwfilter functions require a virConnectPtr. Therefore I am opening a connection in qemudStartup, which later on needs to be closed outside where the driver lock is held since otherwise it ends up in a deadlock due to virConnectClose() trying to lock the driver as well.
      
      I have tested this now for a while with several machines running and needing the IP address learner thread(s). The rebuilding of the firewall rules seems to work fine following libvirtd restart or a SIGHUP. Also the termination of libvirtd worked fine.
      cf6f8b9a
  8. 13 8月, 2010 3 次提交
    • C
      Move the tunnelled migration unix socket to /var/lib/libvirt/qemu · e80f1a7e
      Chris Lalancette 提交于
      Since the qemu process is running as qemu:qemu, it can't actually
      look at the unix socket in /var/run/libvirt/qemu which is owned by
      root and has permission 700.  Move the unix socket to
      /var/lib/libvirt/qemu, which is already owned by qemu:qemu.
      
      Thanks to Justin Clift for test this out for me.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      e80f1a7e
    • C
      Fix tunnelled migration with qemu running as qemu:qemu. · a2f0b6b8
      Chris Lalancette 提交于
      The problem is that on the source of the migration, libvirtd
      is responsible for creating the unix socket over which the data
      will flow.  Since libvirtd is running as root, this file will
      be created as root.  When the qemu process running as qemu:qemu
      goes to access the unix file to write data to it, it will get
      permission denied and fail.  Make sure to change the owner
      of the unix file to qemu:qemu.
      
      Thanks to Justin Clift for testing this patch out for me.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      a2f0b6b8
    • D
      qemu: avoid calling the balloon info command if disabled · 986c2086
      Daniel Veillard 提交于
       Basically a followup of the previous patch about balloon desactivation
      if desactivated, to not ask for balloon information to qemu as we will
      just get an error back.
       This can make a huge difference in the time needed for domain
      information or list when a machine is loaded, and balloon has been
      desactivated in the guests.
      
      * src/qemu/qemu_driver.c: do not get the balloon info if the balloon
        suppor is disabled
      986c2086
  9. 10 8月, 2010 1 次提交
    • J
      qemu: Hack around asynchronous device_del · d1e5676c
      Jiri Denemark 提交于
      device_del command is not synchronous for PCI devices, it merely asks
      the guest to release the device and returns. If the host wants to use
      that device before the guest actually releases it, we are in big
      trouble. To avoid this, we already added a loop which waits up to 10
      seconds until the device is actually released before we do anything else
      with that device. But we only added this loop for managed PCI devices
      before we try reattach them back to the host.
      
      However, we need to wait even for non-managed devices. We don't reattach
      them automatically, but we still want to prevent the host from using it.
      This was revealed thanks to sVirt: when we relabel sysfs files
      corresponding to the PCI device before the guest finished releasing the
      device, qemu is no longer allowed to access those files and if it wants
      (as a result of guest's request) to write anything to them, it just
      exits, which kills the guest.
      
      This is not a proper fix and needs some further work both on libvirt and
      qemu side in the future.
      d1e5676c
  10. 03 8月, 2010 1 次提交
  11. 31 7月, 2010 1 次提交
    • E
      qemu: kill some dead stores · 68e4be71
      Eric Blake 提交于
      Spotted by clang.
      
      * src/qemu/qemu_monitor.c (qemuMonitorClose): Kill dead store.
      * src/qemu/qemu_driver.c (qemudDomainSaveImageStartVM): Likewise.
      68e4be71
  12. 29 7月, 2010 3 次提交
    • C
      Fix a potential race in pciInitDevice. · 56b40823
      Chris Lalancette 提交于
      If detecting the FLR flag of a pci device fails, then we
      could run into the situation of trying to close a file
      descriptor twice, once in pciInitDevice() and once in pciFreeDevice().
      Fix that by removing the pciCloseConfig() in pciInitDevice() and
      just letting pciFreeDevice() handle it.
      
      Thanks to Chris Wright for pointing out this problem.
      
      While we are at it, fix an error check.  While it would actually
      work as-is (since success returns 0), it's still more clear to
      check for < 0 (as the rest of the code does).
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      56b40823
    • C
      qemu: virtio console support · 82b6d760
      Cole Robinson 提交于
      Enable specifying a virtio console device with:
      
      <console type='pty'>
        <target type='virtio'/>
      </console>
      82b6d760
    • C
      domain conf: Rename character prop targetType -> deviceType · 50147933
      Cole Robinson 提交于
      There is actually a difference between the character device type (serial,
      parallel, channel, ...) and the target type (virtio, guestfwd). Currently
      they are awkwardly conflated.
      
      Start to pull them apart by renaming targetType -> deviceType. This is
      an entirely mechanical change.
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      50147933
  13. 28 7月, 2010 1 次提交
  14. 27 7月, 2010 4 次提交
    • C
      pciResetDevice: use inactive devices to determine safe reset · 46bcdb96
      Chris Wright 提交于
      When doing a PCI secondary bus reset, we must be sure that there are no
      active devices on the same bus segment.  The active device tracking is
      designed to only track host devices that are active in use by guests.
      This ignores host devices that are actively in use by the host.  So the
      current logic will reset host devices.
      
      Switch this logic around and allow sbus reset when we are assigning all
      devices behind a bridge to the same guest at guest startup or as a result
      of a single attach-device command.
      
      * src/util/pci.h: change signature of pciResetDevice to add an
        inactive devices list
      * src/qemu/qemu_driver.c src/xen/xen_driver.c: use (or not) the new
        functionality of pciResetDevice() depending on the place of use
      * src/util/pci.c: implement the interface and logic changes
      46bcdb96
    • C
      qemudDomainAttachHostPciDevice refactor to use new helpers · 042b2083
      Chris Wright 提交于
      - src/qemu/qemu_driver.c: Eliminate code duplication by using the new
        helpers qemuPrepareHostdevPCIDevices and qemuDomainReAttachHostdevDevices.
        This reduces the number of open coded calls to pciResetDevice.
      042b2083
    • C
      Add helpers qemuPrepareHostdevPCIDevice and qemuDomainReAttachHostdevDevices · f1365b55
      Chris Wright 提交于
      - src/qemu/qemu_driver.c: These new helpers take hostdev list and count
        directly rather than getting them indirectly from domain definition.
        This will allow reuse for the attach-device case.
      f1365b55
    • C
      qemuGetPciHostDeviceList take hostdev list directly · 8bd00c0e
      Chris Wright 提交于
      - src/qemu/qemu_driver.c: Update qemuGetPciHostDeviceList to take a
        hostdev list and count directly, rather than getting this indirectly
        from domain definition. This will allow reuse for the attach-device case.
      8bd00c0e
  15. 24 7月, 2010 4 次提交
    • C
      Add tests for the new Qemu namespace XML. · a71be01f
      Chris Lalancette 提交于
      Thanks to DV for knocking together the Relax-NG changes
      quickly for me.
      
      Changes since v1:
       - Change the domain.rng to correspond to the new schema
       - Don't allocate caps->ns in testQemuCapsInit since it is a static table
      
      Changes since v2:
       - Change domain.rng to add restrictions on allowed environment names
      
      Changes since v3:
       - Remove a bogus comment in the tests
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      a71be01f
    • C
      Qemu arbitrary monitor commands. · 057e8553
      Chris Lalancette 提交于
      Implement the qemu driver's virDomainQemuMonitorCommand
      and hook it into the API entry point.
      
      Changes since v1:
       - Rename the (external) qemuMonitorCommand to qemuDomainMonitorCommand
       - Add virCheckFlags to qemuDomainMonitorCommand
      
      Changes since v2:
       - Drop ATTRIBUTE_UNUSED from the flags
      
      Changes since v3:
       - Add a flag to priv so we only print out monitor command warning once.  Note
         that this has not been plumbed into qemuDomainObjPrivateXMLFormat or
         qemuDomainObjPrivateXMLParse, which means that if you run a monitor command,
         restart libvirtd, and then run another monitor command, you may get an
         an erroneous VIR_INFO.  It's a pretty minor matter, and I didn't think it
         warranted the additional code.
       - Add BeginJob/EndJob calls around EnterMonitor/ExitMonitor
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      057e8553
    • C
      Qemu Monitor API entry point. · 21adf03c
      Chris Lalancette 提交于
      Add the library entry point for the new virDomainQemuMonitorCommand()
      entry point.  Because this is not part of the "normal" libvirt API,
      it gets its own header file, library file, and will eventually
      get its own over-the-wire protocol later in the series.
      
      Changes since v1:
       - Go back to using the virDriver table for qemuDomainMonitorCommand, due to
         linking issues
       - Added versioning information to the libvirt-qemu.so
      
      Changes since v2:
       - None
      
      Changes since v3:
       - Add LGPL header to libvirt-qemu.c
       - Make virLibConnError and virLibDomainError macros instead of function calls
      
      Changes since v4:
       - Move exported symbols to libvirt_qemu.syms
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      21adf03c
    • C
      Qemu arbitrary command-line arguments. · 869939a5
      Chris Lalancette 提交于
      Implement the qemu hooks for XML namespace data.  This
      allows us to specify a qemu XML namespace, and then
      specify:
      
      <qemu:commandline>
       <qemu:arg value='arg'/>
       <qemu:env name='name' value='value'/>
      </qemu:commandline>
      
      In the domain XML.
      
      Changes since v1:
       - Change the <qemu:arg>arg</qemu:arg> XML to <qemu:arg value='arg'/> XML
       - Fix up some memory leaks in qemuDomainDefNamespaceParse
       - Rename num_extra and extra to num_args and args, respectively
       - Fixed up some error messages
       - Make sure to escape user-provided data in qemuDomainDefNamespaceFormatXML
      
      Changes since v2:
       - Add checking to ensure environment variable names are valid
       - Invert the logic in qemuDomainDefNamespaceFormatXML to return early
      
      Changes since v3:
       - Change strspn() to c_isalpha() check of first letter of environment variable
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      869939a5
  16. 22 7月, 2010 1 次提交
    • L
      Change virFileOperation to return -errno (ie < 0) on error. · 2ad04f78
      Laine Stump 提交于
      virFileOperation previously returned 0 on success, or the value of
      errno on failure. Although there are other functions in libvirt that
      use this convention, the preferred (and more common) convention is to
      return 0 on success and -errno (or simply -1 in some cases) on
      failure. This way the check for failure is always (ret < 0).
      
      * src/util/util.c - change virFileOperation and virFileOperationNoFork to
                          return -errno on failure.
      
      * src/storage/storage_backend.c, src/qemu/qemu_driver.c
        - change the hook functions passed to virFileOperation to return
          -errno on failure.
      2ad04f78
  17. 21 7月, 2010 2 次提交
    • D
      Explicitly represent balloon device in XML and handle PCI address · b2f18635
      Daniel P. Berrange 提交于
      To allow compatibility with older QEMU PCI device slot assignment
      it is necessary to explicitly track the balloon device in the
      XML. This introduces a new device
      
         <memballoon model='virtio|xen'/>
      
      It can also have a PCI address, auto-assigned if necessary.
      
      The memballoon will be automatically added to all Xen and QEMU
      guests by default.
      
      * docs/schemas/domain.rng: Add <memballoon> element
      * src/conf/domain_conf.c, src/conf/domain_conf.h: parsing
        and formatting for memballoon device. Always add a memory
        balloon device to Xen/QEMU if none exists in XML
      * src/libvirt_private.syms: Export memballoon model APIs
      * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Honour the
        PCI device address in memory balloon device
      * tests/*: Update to test new functionality
      b2f18635
    • D
      Remove inappropriate use of VIR_ERR_NO_SUPPORT · 021251bd
      Daniel P. Berrange 提交于
      The VIR_ERR_NO_SUPPORT refers to an API which is not implemented.
      There is a separate VIR_ERR_CONFIG_UNSUPPORTED for XML config
      options that are not available with the current hypervisor.
      
      * src/qemu/qemu_conf.c, src/qemu/qemu_driver.c: Remove
        many VIR_ERR_NO_SUPPORT replace with VIR_ERR_CONFIG_UNSUPPORTED
      021251bd
  18. 20 7月, 2010 4 次提交
    • C
      Fix a deadlock in bi-directional p2p concurrent migration. · f0c8e1cb
      Chris Lalancette 提交于
      If you try to execute two concurrent migrations p2p
      from A->B and B->A, the two libvirtd's will deadlock
      trying to perform the migrations.  The reason for this is
      that in p2p migration, the libvirtd's are responsible for
      making the RPC Prepare, Migrate, and Finish calls.  However,
      they are currently holding the driver lock while doing so,
      which basically guarantees deadlock in this scenario.
      
      This patch fixes the situation by adding
      qemuDomainObjEnterRemoteWithDriver and
      qemuDomainObjExitRemoteWithDriver helper methods.  The Enter
      take an additional object reference, then drops both the
      domain object lock and the driver lock.  The Exit takes
      both the driver and domain object lock, then drops the
      reference.  Adding calls to these Enter and Exit helpers
      around remote calls in the various migration methods
      seems to fix the problem for me in testing.
      
      This should make the situation safe. The additional domain
      object reference ensures that the domain object won't disappear
      while this operation is happening.  The BeginJob that is called
      inside of qemudDomainMigratePerform ensures that we can't execute a
      second migrate (or shutdown, or save, etc) job while the
      migration is active.  Finally, the additional check on the state
      of the vm after we reacquire the locks ensures that we can't
      be surprised by an external event (domain crash, etc).
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      f0c8e1cb
    • D
      Add ability to set a default driver name/type when parsing disks · 03ca4204
      Daniel P. Berrange 提交于
      Record a default driver name/type in capabilities struct. Use this
      when parsing disks if value is not set in XML config.
      
      * src/conf/capabilities.h: Record default driver name/type for disks
      * src/conf/domain_conf.c: Fallback to default driver name/type
        when parsing disks
      * src/qemu/qemu_driver.c: Set default driver name/type to raw
      03ca4204
    • D
      Disable all disk probing in QEMU driver & add config option to re-enable · 68719c4b
      Daniel P. Berrange 提交于
      Disk format probing is now disabled by default. A new config
      option in /etc/qemu/qemu.conf will re-enable it for existing
      deployments where this causes trouble
      68719c4b
    • D
      Pass security driver object into all security driver callbacks · f70e0809
      Daniel P. Berrange 提交于
      The implementation of security driver callbacks often needs
      to access the security driver object. Currently only a handful
      of callbacks include the driver object as a parameter. Later
      patches require this is many more places.
      
      * src/qemu/qemu_driver.c: Pass in the security driver object
        to all callbacks
      * src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
        src/security/security_apparmor.c, src/security/security_driver.h,
        src/security/security_selinux.c: Add a virSecurityDriverPtr
        param to all security callbacks
      f70e0809