1. 19 12月, 2011 1 次提交
    • D
      Convert Xen & VBox drivers to use virDomainEventState · a86bbc60
      Daniel P. Berrange 提交于
      The Xen & VBox drivers deal with callbacks & dispatching of
      events directly. All the other drivers use a timer to dispatch
      events from a clean stack state, rather than deep inside the
      drivers. Convert Xen & VBox over to virDomainEventState so
      that they match behaviour of other drivers
      
      * src/conf/domain_event.c: Return count of remaining
        callbacks when unregistering event callback
      * src/vbox/vbox_tmpl.c, src/xen/xen_driver.c,
        src/xen/xen_driver.h: Convert to virDomainEventState
      a86bbc60
  2. 17 12月, 2011 1 次提交
  3. 16 12月, 2011 4 次提交
    • P
      migration: Add more specific error code/message on migration abort · 8fb2aeb6
      Peter Krempa 提交于
      A generic error code was returned, if the user aborted a migration job.
      This made it hard to distinguish between a user requested abort and an
      error that might have occured. This patch introduces a new error code,
      which is returned in the specific case of a user abort, while leaving
      all other failures with their existing code. This makes it easier to
      distinguish between failure while mirgrating and an user requested
      abort.
      
       * include/libvirt/virterror.h: - add new error code
       * src/util/virterror.c: - add message for the new error code
       * src/qemu/qemu_migration.h: - Emit operation aborted error instead of
                                      operation failed, on migration abort
      8fb2aeb6
    • E
      qemu: detect truncated file as invalid save image · d99fe011
      Eric Blake 提交于
      If managed save fails at the right point in time, then the save
      image can end up with 0 bytes in length (no valid header), and
      our attempts in commit 55d88def to detect and skip invalid save
      files missed this case.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveImageOpen): Also unlink
      empty file as corrupt.  Reported by Dennis Householder.
      d99fe011
    • M
      qemu: Don't drop hostdev config until security label restore · 13d5a6b8
      Michal Privoznik 提交于
      Currently, on device detach, we parse given XML, find the device
      in domain object, free it and try to restore security labels.
      However, in some cases (e.g. usb hostdev) parsed XML contains
      less information than freed device. In usb case it is bus & device
      IDs. These are needed during label restoring as a symlink into
      /dev/bus is generated from them. Therefore don't drop device
      configuration until security labels are restored.
      13d5a6b8
    • J
      Fix default migration speed in qemu driver · d8916dc8
      Jim Fehlig 提交于
      In commit 6f84e110 I mistakenly set default migration speed to
      33554432 Mb!  The units of migMaxBandwidth is Mb, with conversion
      handled in qemuMonitor{JSON,Text}SetMigrationSpeed().
      
      Also, remove definition of QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX since
      it is no longer used after reverting commit ef1065cf.
      d8916dc8
  4. 15 12月, 2011 3 次提交
    • J
      qemu: Fix race between async and query jobs · 6948b725
      Jiri Denemark 提交于
      If an async job run on a domain will stop the domain at the end of the
      job, a concurrently run query job can hang in qemu monitor and nothing
      can be done with that domain from this point on. An attempt to start
      such domain results in "Timed out during operation: cannot acquire state
      change lock" error.
      
      However, quite a few things have to happen at the right time... There
      must be an async job running which stops a domain at the end. This race
      was reported with dump --crash but other similar jobs, such as
      (managed)save and migration, should be able to trigger this bug as well.
      While this async job is processing its last monitor command, that is a
      query-migrate to which qemu replies with status "completed", a new
      libvirt API that results in a query job must arrive and stay waiting
      until the query-migrate command finishes. Once query-migrate is done but
      before the async job closes qemu monitor while stopping the domain, the
      other thread needs to wake up and call qemuMonitorSend to send its
      command to qemu. Before qemu gets a chance to respond to this command,
      the async job needs to close the monitor. At this point, the query job
      thread is waiting for a condition that no-one will ever signal so it
      never finishes the job.
      6948b725
    • O
      qemu: Do not free the device from activePciHostdevs if it's in use · 3f29d6c9
      Osier Yang 提交于
      * src/qemu/qemu_hostdev.c (qemuDomainReAttachHostdevDevices):
      pciDeviceListFree(pcidevs) in the end free()s the device even if
      it's in use by other domain, which can cause a race.
      
      How to reproduce:
      
      <script>
      
      virsh nodedev-dettach pci_0000_00_19_0
      virsh start test
      virsh attach-device test hostdev.xml
      virsh start test2
      
      for i in {1..5}; do
              echo "[ -- ${i}th time --]"
              virsh nodedev-reattach pci_0000_00_19_0
      done
      
      echo "clean up"
      virsh destroy test
      virsh nodedev-reattach pci_0000_00_19_0
      </script>
      
      Device pci_0000_00_19_0 dettached
      
      Domain test started
      
      Device attached successfully
      
      error: Failed to start domain test2
      error: Requested operation is not valid: PCI device 0000:00:19.0 is in use by domain test
      
      [ -- 1th time --]
      Device pci_0000_00_19_0 re-attached
      
      [ -- 2th time --]
      Device pci_0000_00_19_0 re-attached
      
      [ -- 3th time --]
      Device pci_0000_00_19_0 re-attached
      
      [ -- 4th time --]
      Device pci_0000_00_19_0 re-attached
      
      [ -- 5th time --]
      Device pci_0000_00_19_0 re-attached
      
      clean up
      Domain test destroyed
      
      Device pci_0000_00_19_0 re-attached
      
      The patch also fixes another problem, there won't be error like
      "qemuDomainReAttachHostdevDevices: Not reattaching active
      device 0000:00:19.0" in daemon log if some device is in active.
      As pciResetDevice and pciReattachDevice won't be called for
      the device anymore. This is sensible as we already reported
      error when preparing the device if it's active. Blindly trying
      to pciResetDevice & pciReattachDevice on the device and getting
      an error is just redundant.
      3f29d6c9
    • O
      qemu: Honor the original properties of PCI device when detaching · a0aec362
      Osier Yang 提交于
      This patch fixes two problems:
          1) The device will be reattached to host even if it's not
             managed, as there is a "pciDeviceSetManaged".
          2) The device won't be reattached to host with original
             driver properly. As it doesn't honor the device original
             properties which are maintained by driver->activePciHostdevs.
      a0aec362
  5. 14 12月, 2011 1 次提交
  6. 13 12月, 2011 1 次提交
    • O
      storage: Fix a potential crash when creating vol object · 380f3269
      Osier Yang 提交于
      If the vol object is newly created, it increases the volumes count,
      but doesn't decrease the volumes count when do cleanup. It can
      cause libvirtd to crash when one trying to free the volume objects
      like:
          for (i = 0; i < pool->volumes.count; i++)
              virStorageVolDefFree(pool->volumes.objs[i]);
      
      It's more reliable if we add the newly created vol object in the
      end.
      380f3269
  7. 12 12月, 2011 3 次提交
  8. 10 12月, 2011 9 次提交
    • L
      network: don't add iptables rules for externally managed networks · ae1232b2
      Laine Stump 提交于
      This patch addresses https://bugzilla.redhat.com/show_bug.cgi?id=760442
      
      When a network has any forward type other than route, nat or none, the
      network configuration should be done completely external to libvirt -
      libvirt only uses these types to allow configuring guests in a manner
      that isn't tied to a specific host (all the host-specific information,
      in particular interface names, port profile data, and bandwidth
      configuration is in the network definition, and the guest
      configuration only references it).
      
      Due to a bug in the bridge network driver, libvirt was adding iptables
      rules for networks with forward type='bridge' etc. any time libvirtd
      was restarted while one of these networks was active.
      
      This patch eliminates that error by only "reloading" iptables rules if
      forward type is route, nat, or none.
      ae1232b2
    • M
      qemu: Prepare to cater for more general address assignment · 9f406c58
      Michael Ellerman 提交于
      Currently qemuDomainAssignPCIAddresses() is called to assign addresses
      to PCI devices.
      
      We need to do something similar for devices with spapr-vio addresses.
      So create one place where address assignment will be done, that is
      qemuDomainAssignAddresses().
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      9f406c58
    • M
      qemu: Add address in qemuBuildChrDeviceStr() on pseries · 2a994a3b
      Michael Ellerman 提交于
      For the PPC64 pseries machine type we need to add address information
      for the spapr-vty device.
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      2a994a3b
    • M
      qemu: Use spapr-vscsi on pseries machine type · e1636f47
      Michael Ellerman 提交于
      On the PPC64 pseries machine type we need to use the spapr-vscsi device
      rather than an lsi.
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      e1636f47
    • E
      network: allow '-' in model name · dad3c209
      Eric Blake 提交于
      In QEMU PPC64 we have a network device called "spapr-vlan". We can specify
      this using the existing syntax for network devices, however libvirt
      currently rejects "spapr-vlan" in virDomainNetDefParseXML() because of
      the "-". Fix the code to accept "-".
      
      * src/conf/domain_conf.c (virDomainNetDefParseXML): Allow '-' in
      model name, and be more efficient.
      * docs/schemas/domaincommon.rng: Limit valid model names to match code.
      Based on a patch by Michael Ellerman.
      dad3c209
    • M
      threadpool: Use while loop on virCondWait · a7adac37
      Michal Privoznik 提交于
      instead of simple 'if' statement as virCondWait can return
      even if associated condition was not signaled.
      a7adac37
    • M
      threads: Document spurious wakeups on virCondWait · 6c811ed4
      Michal Privoznik 提交于
      6c811ed4
    • S
      fix error when parsing ppc64 models on x86 host · 84f56333
      Stefan Berger 提交于
      When parsing ppc64 models on an x86 host an out-of-memory error message is displayed due
      to it checking for retcpus being NULL. Fix this by removing the check whether retcpus is NULL
      since we will realloc into this variable.
      Also in the X86 model parser display the OOM error at the location where it happens.
      84f56333
    • S
      fix memory leak in src/nodeinfo.c · b1d6d56c
      Stefan Berger 提交于
      Fix memory leak:
      
      ==27534== 24 bytes in 1 blocks are definitely lost in loss record 207 of 530
      ==27534==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
      ==27534==    by 0x38EC26EC37: vasprintf (in /lib64/libc-2.13.so)
      ==27534==    by 0x4E998E6: virVasprintf (util.c:1677)
      ==27534==    by 0x4E999F1: virAsprintf (util.c:1695)
      ==27534==    by 0x4F1EAAC: nodeGetInfo (nodeinfo.c:593)
      ==27534==    by 0x47948F: qemuCapsInitCPU (qemu_capabilities.c:855)
      ==27534==    by 0x4796B1: qemuCapsInit (qemu_capabilities.c:915)
      ==27534==    by 0x456550: qemuCreateCapabilities (qemu_driver.c:245)
      ==27534==    by 0x4578C4: qemudStartup (qemu_driver.c:580)
      ==27534==    by 0x4F20886: virStateInitialize (libvirt.c:852)
      ==27534==    by 0x420E55: daemonRunStateInit (libvirtd.c:1156)
      ==27534==    by 0x4E94C56: virThreadHelper (threads-pthread.c:157)
      
      Mark this leaked variable as const char * when it is passed into another
      function. 
      b1d6d56c
  9. 09 12月, 2011 6 次提交
    • M
      threadpool: Don't wait on condition if pool has no workers · 3b0bb65d
      Michal Privoznik 提交于
      Pool creates new workers dynamically. However, it is possible
      for a pool to have no workers. If we want to free that pool,
      we don't want to wait on quit condition as it will never be
      signaled.
      3b0bb65d
    • J
      bridge: Fix forward delay APIs · 2d5046d3
      Jiri Denemark 提交于
      Due to copy&paste error in c1df2c14,
      virNetDevBridge[SG]etSTPDelay APIs were accessing wrong file.
      2d5046d3
    • P
      cpu: Add cpu flags supported by newest qemu · b2cb24f4
      Peter Krempa 提交于
      Add support for newly supported Intel cpu features. Newly supported
      flags are: pclmuldq, dtes64, smx, fma, pdcm, movbe, xsave, osxsave and
      avx. This adds support for Intel's Sandy Bridge platform.
      b2cb24f4
    • S
      Pass the VM's UUID into the nwfilter subsystem · 33eb3567
      Stefan Berger 提交于
      A preparatory patch for DHCP snooping where we want to be able to
      differentiate between a VM's interface using the tuple of
      <VM UUID, Interface MAC address>. We assume that MAC addresses could
      possibly be re-used between different networks (VLANs) thus do not only
      want to rely on the MAC address to identify an interface.
      
      At the current 'final destination' in virNWFilterInstantiate I am leaving
      the vmuuid parameter as ATTRIBUTE_UNUSED until the DHCP snooping patches arrive.
      (we may not post the DHCP snooping patches for 0.9.9, though)
      
      Mostly this is a pretty trivial patch. On the lowest layers, in lxc_driver
      and uml_conf, I am passing the virDomainDefPtr around until I am passing
      only the VM's uuid into the NWFilter calls.
      33eb3567
    • S
      nwfilter: cleanup return codes in nwfilter subsystem · 95ff5899
      Stefan Berger 提交于
      This patch cleans up return codes in the nwfilter subsystem.
      
      Some functions in nwfilter_conf.c (validators and formatters) are
      keeping their bool return for now and I am converting their return
      code to true/false.
      
      All other functions now have failure return codes of -1 and success
      of 0.
      
      [I searched for all occurences of ' 1;' and checked all 'if ' and
      adapted where needed. After that I did a grep for 'NWFilter' in the source
      tree.]
      95ff5899
    • L
      test: fix potential lock corruption in test driver · f21d4914
      Laine Stump 提交于
      In some error situations, the function testDomainRestoreFlags() could
      unlock the test driver mutex without first locking it. This patch
      moves the lock operation earlier, so that it occurs before any
      potential jump down to the unlock call.
      
      I found this problem while auditing the test driver lock usage to
      determine the cause of a hang while running the following test:
      
        cd tests; while true; do printf x; ./undefine; done
      
      This patch *does not* solve that problem, but we now understand its
      actual source, and danpb is working on a patch.
      f21d4914
  10. 08 12月, 2011 9 次提交
    • D
      When checking nttyFDs to see if it is != 1, be sure to use '1' and not '-1' · 4d82fa68
      Daniel P. Berrange 提交于
      * src/lxc/lxc_controller.c: Fix check for tty count
      4d82fa68
    • P
      Clean up qemuBuildCommandLine to remove x86-specific · 5e6ce1c9
      Prerna Saxena 提交于
       assumptions from generic code.
      
      This implements the minimal set of changes needed in libvirt to launch a
      PowerPC-KVM based guest.
      It removes x86-specific assumptions about choice of serial driver backend
      from generic qemu guest commandline generation code.
      It also restricts the ACPI capability to be available for an x86 or
      x86_64 domain.
      This is not a complete solution -- it still does not guarantee libvirt
      the capability to flag non-supported options in guest XML. (Eg, an ACPI
      specification in a PowerPC guest XML will still get processed, even
      though qemu-system-ppc64 does not support it while qemu-system-x86_64 does.)
      This drawback exists because libvirt falls back on qemu to query supported
      features, and qemu '-h' blindly lists all capabilities -- irrespective
      of whether they are available while emulating a given architecture or not.
      The long-term solution would be for qemu to list out capabilities based
      on architecture and platform -- so that libvirt can cleanly make out what
      devices are supported on an arch (say 'ppc64') and platform (say, 'mac99').
      Signed-off-by: NPrerna Saxena <prerna@linux.vnet.ibm.com>
      5e6ce1c9
    • P
      Add support for ppc64 qemu · 9bb8064d
      Prerna Saxena 提交于
      This enables libvirt to select the correct qemu binary (qemu-system-ppc64)
      for a guest vm based on arch 'ppc64'.
      Also, libvirt is enabled to correctly parse the list of supported PowerPC
      CPUs, generated by running 'qemu-system-ppc64 -cpu ?'
      Signed-off-by: NPrerna Saxena <prerna@linux.vnet.ibm.com>
      Acked-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      9bb8064d
    • P
      Use sysfs to gather host topology, in place of · f99b3b4b
      Prerna Saxena 提交于
       /proc/cpuinfo
      
      Libvirt at present depends on /proc/cpuinfo to gather host
      details such as CPUs, cores, threads, etc. This is an architecture-
      dependent approach. An alternative is to use 'Sysfs', which provides
      a platform-agnostic interface to parse host CPU topology.
      Signed-off-by: NPrerna Saxena <prerna@linux.vnet.ibm.com>
      f99b3b4b
    • E
      build: fix build with older libxml2 · f59a9417
      Eric Blake 提交于
      On RHEL 5, with libxml2-2.6.26, the build failed with:
      virsh.c: In function 'vshNodeIsSuperset':
      virsh.c:11951: warning: implicit declaration of function 'xmlChildElementCount'
      
      (or if warnings aren't errors, a link failure later on).
      
      * src/util/xml.h (virXMLChildElementCount): New prototype.
      * src/util/xml.c (virXMLChildElementCount): New function.
      * src/libvirt_private.syms (xml.h): Export it.
      * tools/virsh.c (vshNodeIsSuperset): Use it.
      f59a9417
    • D
      Fix updating of haveTheBuck in RPC client to be race-free · e9708637
      Daniel P. Berrange 提交于
      When one thread passes the buck to another thread, it uses
      virCondSignal to wake up the target thread. The variable
      'haveTheBuck' is not updated in a race-free manner when
      this occurs. The current thread sets it to false, and the
      woken up thread sets it to true. There is a window where
      a 3rd thread can come in and grab the buck.
      
      Even if this didn't lead to crashes & deadlocks, this would
      still result in unfairness in the buckpassing algorithm.
      
      A better solution is to *never* set haveTheBuck to false
      when we're passing the buck. Only set it to false when there
      is no further thread waiting for the buck.
      
      * src/rpc/virnetclient.c: Only set haveTheBuck to false
        if no thread is waiting
      e9708637
    • D
      Revert fd066925 · 50a4f49c
      Daniel P. Berrange 提交于
      Commit fd066925 tried to fix
      a race condition in
      
        commit fa959500
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Fri Nov 11 15:28:41 2011 +0000
      
          Explicitly track whether the buck is held in remote client
      
      Unfortunately there is a second race condition whereby the
      event loop can trigger due to incoming data to read. Revert
      this fix, so a complete fix for the problem can be cleanly
      applied
      
      * src/rpc/virnetclient.c: Revert fd066925
      50a4f49c
    • J
      Prevent crash of libvirtd when attaching to existing qemu process · 28423019
      Jim Fehlig 提交于
      With security_driver set to "none" in /etc/libvirt/qemu.conf,
      libvirtd would crash when attempted to attach to an existing
      qemu process.  Only copy the security model if it actually exists.
      28423019
    • C
      Fix typo in virDomainResume API doc · 9fdfd8b6
      Christophe Fergeau 提交于
      It's referring to virSuspendDomain instead of
      virDomainSuspend.
      9fdfd8b6
  11. 07 12月, 2011 2 次提交
    • J
      qemu: Ignore shutdown event from destroyed domain · 97652044
      Jiri Denemark 提交于
      During virDomainDestroy, QEMU may emit SHUTDOWN event as a response to
      SIGTERM and since domain object is still locked, the event is processed
      after the domain is destroyed. We need to ignore this event in such case
      to avoid changing domain state from shutoff to shutdown.
      97652044
    • O
      npiv: Expose fabric_name outside · cc17f092
      Osier Yang 提交于
      This patch is to expose the fabric_name of fc_host class, which
      might be useful for users who wants to known which fabric the
      (v)HBA connects to.
      
      The patch also adds the missed capabilities' XML schema of scsi_host,
      (of course, with fabric_wwn added), and update the documents
      (docs/formatnode.html.in)
      cc17f092