1. 10 4月, 2013 1 次提交
    • P
      conf: Fix race between looking up a domain object and freeing it · b7c98329
      Peter Krempa 提交于
      This patch fixes crash of the daemon that happens due to the following race
      condition:
      
      Let's have two threads in the libvirtd daemon's qemu driver:
      A - thread executing undefine on the same domain
      B - thread executing a API call to get information about a domain
      
      Assume following serialization of operations done by the threads:
      1) A has the lock on the domain object and is executing some code prior to
         virDomainObjListRemove()
      2) B takes the lock on the domain object list, looks up the domain object
      pointer and blocks in the attempt to lock the domain object as A is holding the
      lock
      3) A reaches virDomainObjListRemove() and unlocks the lock on the domain object
      4) A blocks on the attempt to get the domain list lock
      5) B is able to lock the domain object now and unlocks the domain list
      6) A is now able to lock the domain list, and sheds the last reference on the
      domain object, this triggers the freeing function.
      6) B starts executing the code on the pointer that is being freed
      7) The libvirtd daemon crashes while attempting to access invalid pointer in
      thread B.
      
      This patch fixes the race by acquiring a reference on the domain object before
      unlocking it in virDomainObjListRemove() and re-locks the object prior to
      removing and freeing it. This ensures that no thread holds a lock on the domain
      object at the time it is removed from the list, and that doing a list lookup
      will never find a domain that is about to vanish.
      
      This is a minimal fix of the problem, but a better solution will be to switch to
      full reference counting for domain objects.
      b7c98329
  2. 09 4月, 2013 2 次提交
  3. 08 4月, 2013 4 次提交
    • O
      Support seclabels for volume type disk · 664270b8
      Osier Yang 提交于
      "seclabels" is only valid for 'file' or 'block' type storage volume.
      664270b8
    • O
      Support startupPolicy for 'volume' disk · 43404fee
      Osier Yang 提交于
      "startupPolicy" is only valid for file type storage volume, otherwise
      it fails on starting the domain.
      43404fee
    • O
      Introduce new XMLs to specify disk source using libvirt storage · 4bc331c8
      Osier Yang 提交于
      With this patch, one can specify the disk source using libvirt
      storage like:
      
        <disk type='volume' device='disk'>
          <driver name='qemu' type='raw' cache='none'/>
          <source pool='default' volume='fc18.img'/>
          <target dev='vdb' bus='virtio'/>
        </disk>
      
      "seclabels" and "startupPolicy" are not supported for this new
      disk type ("volume"). They will be supported in later patches.
      
      docs/formatdomain.html.in:
        * Add documents for new XMLs
      docs/schemas/domaincommon.rng:
        * Add rng for new XMLs;
      src/conf/domain_conf.h:
        * New struct for 'volume' type disk source (virDomainDiskSourcePoolDef)
        * Add VIR_DOMAIN_DISK_TYPE_VOLUME for enum virDomainDiskType
      src/conf/domain_conf.c:
        * New helper virDomainDiskSourcePoolDefParse to parse the 'volume'
          type disk source.
        * New helper virDomainDiskSourcePoolDefFree to free the source def
          if 'volume' type disk.
      tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml:
      tests/qemuxml2xmltest.c:
        * New test
      4bc331c8
    • O
      conf: New helper virDomainDiskSourceDefFormat to format the disk source · a05b0fc1
      Osier Yang 提交于
      The code to format disk source is long enough to have a helper.
      a05b0fc1
  4. 06 4月, 2013 1 次提交
    • O
      qemu: Support multiple queue virtio-scsi · d4bf0a93
      Osier Yang 提交于
      This introduce a new attribute "num_queues" (same with the good name
      QEMU uses) for virtio-scsi controller. An example of the XML:
      
      <controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
      
      The corresponding QEMU command line:
      
      -device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
      d4bf0a93
  5. 05 4月, 2013 10 次提交
    • P
      virCaps: get rid of defaultConsoleTargetType callback · 482e5f15
      Peter Krempa 提交于
      This patch refactors various places to allow removing of the
      defaultConsoleTargetType callback from the virCaps structure.
      
      A new console character device target type is introduced -
      VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was
      specified in the XML. This type is at the end converted to the standard
      VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are
      different from this default have to be processed separately in the
      device post parse callback.
      482e5f15
    • P
      virCaps: get rid of macPrefix field · 46becc18
      Peter Krempa 提交于
      Use the virDomainXMLConf structure to hold this data and tweak the code
      to avoid semantic change.
      
      Without configuration the KVM mac prefix is used by default. I chose it
      as it's in the privately administered segment so it should be usable for
      any purposes.
      46becc18
    • P
      virCaps: get rid of hasWideScsiBus · 8960d656
      Peter Krempa 提交于
      Use the virDomainXMLConf structure to hold this data.
      8960d656
    • P
      virCaps: get rid of defaultDiskDriverType · b2990849
      Peter Krempa 提交于
      Use the qemu specific callback to fill this data in the qemu driver as
      it's the only place where it was used and fix tests as the qemu test
      capability object didn't configure the defaults for the tests.
      b2990849
    • P
      virCaps: get rid of emulatorRequired · b5def001
      Peter Krempa 提交于
      This patch removes the emulatorRequired field and associated
      infrastructure from the virCaps object. Instead the driver specific
      callbacks are used as this field isn't enforced by all drivers.
      
      This patch implements the appropriate callbacks in the qemu and lxc
      driver and moves to check to that location.
      b5def001
    • P
      virCaps: get rid of defaultDiskDriverName · 9ea249e7
      Peter Krempa 提交于
      This patch removes the defaultDiskDriverName from the virCaps
      structure. This particular default value is used only in the qemu driver
      so this patch uses the recently added callback to fill the driver name
      if it's needed instead of propagating it through virCaps.
      9ea249e7
    • P
      virCaps: get rid of "defaultInitPath" value in the virCaps struct · 4750c848
      Peter Krempa 提交于
      This gets rid of the parameter in favor of using the new callback
      infrastructure to do the same stuff.
      
      This patch implements the domain adjustment callback in the openVZ
      driver and moves the check from the parser to a new validation method in
      the callback infrastructure.
      4750c848
    • P
      conf callback: Rearrange function parameters · ad0d10b2
      Peter Krempa 提交于
      Move the xmlopt and caps arguments to the end of the argument list.
      ad0d10b2
    • P
      conf: Add post XML parse callbacks and prepare for cleaning of virCaps · 43b99fc4
      Peter Krempa 提交于
      This patch adds instrumentation that will allow hypervisor drivers to
      fill and validate domain and device definitions after parsed by the XML
      parser.
      
      With this patch, after the XML is parsed, a callback to the driver is
      issued requesting to fill and validate driver specific details of the
      configuration. This allows to use sensible defaults and checks on a per
      driver basis at the time the XML is parsed.
      
      Two callback pointers are stored in the new virDomainXMLConf object:
      * virDomainDeviceDefPostParseCallback (devicesPostParseCallback)
        - called for a single device parsed and for every single device in a
          domain config. A virDomainDeviceDefPtr is passed along with the
          domain definition and virCaps.
      
      * virDomainDefPostParseCallback, (domainPostParseCallback)
        - A callback that is meant to process the domain config after it's
        parsed.  A virDomainDefPtr is passed along with virCaps.
      
      Both types of callbacks support arbitrary opaque data passed for the
      callback functions.
      
      Errors may be reported in those callbacks resulting in a XML parsing
      failure.
      43b99fc4
    • P
      maint: Rename xmlconf to xmlopt and virDomainXMLConfig to virDomainXMLOption · e84b1931
      Peter Krempa 提交于
      This patch is the result of running:
      
      for i in $(git ls-files | grep -v html | grep -v \.po$ ); do
        sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i
      done
      
      and a few manual tweaks.
      e84b1931
  6. 02 4月, 2013 2 次提交
  7. 28 3月, 2013 1 次提交
  8. 27 3月, 2013 1 次提交
    • G
      conf: fix a failure when detaching a usb device · a950f03e
      Guannan Ren 提交于
       #virsh detach-device $guest usb.xml
       error: Failed to detach device from usb2.xml
       error: operation failed: host usb device vendor=0x0951 \
       product=0x1625 not found
      
      This regresstion is due to a typo in matching function. The first
      argument is always the usb device that we are checking for. If the
      usb xml file provided by user contains bus and device info, we try
      to search it by them, otherwise, we use vendor and product info.
      
      The bug occurred only when detaching a usb device with no bus and
      device info provided in the usb xml file.
      a950f03e
  9. 23 3月, 2013 1 次提交
  10. 22 3月, 2013 3 次提交
  11. 21 3月, 2013 1 次提交
  12. 20 3月, 2013 2 次提交
  13. 14 3月, 2013 2 次提交
    • P
      virtio-rng: Add rate limiting options for virtio-RNG · 32bd699f
      Peter Krempa 提交于
      Qemu's implementation of virtio RNG supports rate limiting of the
      entropy used. This patch exposes the option to tune this functionality.
      
      This patch is based on qemu commit 904d6f588063fb5ad2b61998acdf1e73fb4
      
      The rate limiting is exported in the XML as:
      <devices>
        ...
        <rng model='virtio'>
          <rate bytes='123' period='1234'/>
          <backend model='random'/>
        </rng>
        ...
      32bd699f
    • V
      S390: domain_conf support for CCW · e50a1bae
      Viktor Mihajlovski 提交于
      Add necessary handling code for the new s390 CCW address type to
      virDomainDeviceInfo. Further, introduce  memory management, XML
      parsing, output formatting and range validation for the new
      virDomainDeviceCCWAddress type.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      e50a1bae
  14. 13 3月, 2013 1 次提交
    • P
      virCaps: conf: start splitting out irrelevat data · 27cf98e2
      Peter Krempa 提交于
      The virCaps structure gathered a ton of irrelevant data over time that.
      The original reason is that it was propagated to the XML parser
      functions.
      
      This patch aims to create a new data structure virDomainXMLConf that
      will contain immutable data that are used by the XML parser. This will
      allow two things we need:
      
      1) Get rid of the stuff from virCaps
      
      2) Allow us to add callbacks to check and add driver specific stuff
      after domain XML is parsed.
      
      This first attempt removes pointers to private data allocation functions
      to this new structure and update all callers and function that require
      them.
      27cf98e2
  15. 07 3月, 2013 2 次提交
    • D
      Fix crash parsing RNG device specification · 75e656a3
      Daniel P. Berrange 提交于
      Code that validates the whitelist for the RNG device filename
      didn't account for fact that filename may be NULL. This led
      to a NULL reference crash. This wasn't caught since the test
      suite was not covering this XML syntax
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      75e656a3
    • J
      Resolve valgrind error · 1cf4ef1f
      John Ferlan 提交于
      Resolves the following valgrind error from qemuxml2argvtest:
      
      ==20393== 5 bytes in 1 blocks are definitely lost in loss record 2 of 60
      ==20393==    at 0x4A0883C: malloc (vg_replace_malloc.c:270)
      ==20393==    by 0x38D690A167: __vasprintf_chk (in /usr/lib64/libc-2.16.so)
      ==20393==    by 0x4CB0D97: virVasprintf (stdio2.h:210)
      ==20393==    by 0x4CB0E53: virAsprintf (virutil.c:2017)
      ==20393==    by 0x428DC5: qemuAssignDeviceAliases (qemu_command.c:791)
      ==20393==    by 0x41DF93: testCompareXMLToArgvHelper (qemuxml2argvtest.c:151)
      ==20393==    by 0x41F53F: virtTestRun (testutils.c:157)
      ==20393==    by 0x41DA9B: mymain (qemuxml2argvtest.c:885)
      ==20393==    by 0x41FB7A: virtTestMain (testutils.c:719)
      ==20393==    by 0x38D6821A04: (below main) (in /usr/lib64/libc-2.16.so)
      ==20393==
      
      From qemu_command.c/line 791:
      
          if (def->rng) {
              if (virAsprintf(&def->rng->info.alias, "rng%d", 0) < 0)
                  goto no_memory;
          }
      1cf4ef1f
  16. 05 3月, 2013 4 次提交
    • P
      conf: Report errors on cputune parameter parsing · 7fc4864a
      Peter Krempa 提交于
      This patch adds proper error reporting if parsing of cputune parameters
      fails due to incorrect values provided by the user. Previously no errors
      were reported in such a case and the failure was silently ignored.
      7fc4864a
    • P
      conf: Make virDomainDeviceInfoIterate usable without os type · 5d9169e4
      Peter Krempa 提交于
      Make the iterator function usable in the next patches. Also refactor
      some parts to avoid strcmp if not necessary.
      
      This commit tweaks and shadows the change that was done in commit
      babe7dad and was needed after the
      support for multiple console devices was added. Historically the first
      <console> element is alias for the <serial> device.
      5d9169e4
    • P
      conf: whitespace cleanups and refactors with no semantic impact · bb98ba5d
      Peter Krempa 提交于
      This patch changes many unrelated places to simplify the code or update
      code style. This patch should not have any semantic impact on the code.
      bb98ba5d
    • E
      rng: restrict passthrough names to known-good files · 4932ef45
      Eric Blake 提交于
      There is some controversy[1] on the qemu list on whether qemu should
      have ever allowed arbitrary file name passthrough, or whether it
      should be restricted to JUST /dev/random and /dev/hwrng.  It is
      always easier to add support for additional filenames than it is
      to remove support for something once released, so this patch
      restricts libvirt 1.0.3 (where the virtio-random backend was first
      supported) to just the two uncontroversial names, letting us defer
      to a later date any decision on whether supporting arbitrary files
      makes sense. Additionally, since qemu 1.4 does NOT support
      /dev/fdset/nnn fd passthrough for the backend, limiting to just
      two known names means that we don't get tempted to try fd
      passthrough where it won't work.
      
      [1]https://lists.gnu.org/archive/html/qemu-devel/2013-03/threads.html#00023
      
      * src/conf/domain_conf.c (virDomainRNGDefParseXML): Only allow
      /dev/random and /dev/hwrng.
      * docs/schemas/domaincommon.rng: Flag invalid files.
      * docs/formatdomain.html.in (elementsRng): Document this.
      * tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args:
      Update test to match.
      * tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml:
      Likewise.
      4932ef45
  17. 27 2月, 2013 1 次提交
  18. 26 2月, 2013 1 次提交