1. 02 12月, 2013 6 次提交
    • P
      conf: Add functions to copy and free network disk source definitions · ae361674
      Peter Krempa 提交于
      To simplify operations on virDomainDiskHostDef arrays we will need deep
      copy and freeing functions. Add and properly export them.
      ae361674
    • P
      conf: Export disk source formatter and parser · 5f86d11e
      Peter Krempa 提交于
      This code will be reused in the snapshot disk definition parser.
      5f86d11e
    • P
      conf: Split out seclabel formating code for disk source · 30f7ca67
      Peter Krempa 提交于
      The code is common for all the various disk types. Split it out to a
      common function.
      30f7ca67
    • P
      conf: Clean up virDomainDiskSourceDefFormatInternal · 03ad83cb
      Peter Krempa 提交于
      Avoid if statements when used with virBufferEscapeString which
      automaticaly omits the whole string. Also add some line breaks to
      visualy separate the code.
      03ad83cb
    • P
      conf: Support disk source formatting without needing a virDomainDiskDefPtr · d6b4c2cc
      Peter Krempa 提交于
      The <source> element formatting function was expecting a
      virDomainDiskDefPtr to store the data. As snapshots are not using this
      data structure to hold the data, we need to add an internal function
      which splits out individual fields separately.
      d6b4c2cc
    • N
      Fix memory leak in virDomainDefParseXML() · 2cfcd2cc
      Nehal J Wani 提交于
      This patch fixes the memory leaks found while running qemuxml2argvtest
      
      ==8260== 3 bytes in 1 blocks are definitely lost in loss record 1 of
      129
      ==8260==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==8260==    by 0x341F485E21: strdup (strdup.c:42)
      ==8260==    by 0x4CADCFF: virStrdup (virstring.c:554)
      ==8260==    by 0x4CBB839: virXPathString (virxml.c:90)
      ==8260==    by 0x4CE753A: virDomainDefParseXML (domain_conf.c:11478)
      ==8260==    by 0x4CEB4FE: virDomainDefParseNode (domain_conf.c:12742)
      ==8260==    by 0x4CEB675: virDomainDefParse (domain_conf.c:12684)
      ==8260==    by 0x425958: testCompareXMLToArgvHelper (qemuxml2argvtest.c:107)
      ==8260==    by 0x427111: virtTestRun (testutils.c:138)
      ==8260==    by 0x41D3FE: mymain (qemuxml2argvtest.c:452)
      ==8260==    by 0x4277B2: virtTestMain (testutils.c:593)
      ==8260==    by 0x341F421A04: (below main) (libc-start.c:225)
      ==8260==
      ==8260== 4 bytes in 1 blocks are definitely lost in loss record 5 of
      129
      ==8260==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
      ==8260==    by 0x341F485E21: strdup (strdup.c:42)
      ==8260==    by 0x4CADCFF: virStrdup (virstring.c:554)
      ==8260==    by 0x4CBB839: virXPathString (virxml.c:90)
      ==8260==    by 0x4CE753A: virDomainDefParseXML (domain_conf.c:11478)
      ==8260==    by 0x4CEB4FE: virDomainDefParseNode (domain_conf.c:12742)
      ==8260==    by 0x4CEB675: virDomainDefParse (domain_conf.c:12684)
      ==8260==    by 0x425958: testCompareXMLToArgvHelper (qemuxml2argvtest.c:107)
      ==8260==    by 0x427111: virtTestRun (testutils.c:138)
      ==8260==    by 0x41D39A: mymain (qemuxml2argvtest.c:451)
      ==8260==    by 0x4277B2: virtTestMain (testutils.c:593)
      ==8260==    by 0x341F421A04: (below main) (libc-start.c:225)
      ==8260==
      2cfcd2cc
  2. 26 11月, 2013 1 次提交
  3. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: conf · 6f4901e1
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/conf/capabilities.c: Consistently use commas.
      * src/conf/domain_conf.c: Likewise.
      * src/conf/network_conf.c: Likewise.
      * src/conf/storage_conf.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6f4901e1
  4. 12 11月, 2013 3 次提交
  5. 11 11月, 2013 1 次提交
    • M
      virSecurityLabelDefParseXML: Don't parse label on model='none' · 9fb3f957
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1027096
      
      If there's the following snippet in the domain XML, the domain will be
      lost upon the daemon restart (if the domain is started prior restart):
      
          <seclabel type='dynamic' relabel='yes'/>
      
      The problem is, the 'label', 'imagelabel' and 'baselabel' are parsed
      whenever the VIR_DOMAIN_XML_INACTIVE is *not* present or the label is
      static. The latter is not our case, obviously. So, when libvirtd starts
      up, it finds domain state xml and parse it. During parsing, many XML
      flags are enabled but VIR_DOMAIN_XML_INACTIVE. Hence, our parser tries
      to extract 'label', 'imagelabel' and 'baselabel' from the XML which
      fails for model='none'. Err, this model - even though not specified in
      XML - can be taken from qemu wide config file: /etc/libvirtd/qemu.conf.
      
      However, in order to know we are dealing with model='none' the code in
      question must be moved forward a bit. Then a new check must be
      introduced. This is what the first two chunks are doing.
      
      But this alone is not sufficient. The domain state XML won't contain the
      model attribute without slight modification. The model should be
      inserted into the XML even if equal to 'none' and the state XML is being
      generated - what if the origin (the @security_driver variable in
      qemu.conf) changes during libvirtd restarts?
      
      At the end, a test to catch this scenario is introduced.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9fb3f957
  6. 08 11月, 2013 2 次提交
    • P
      qemu: Add support for paravirtual spinlocks in the guest · e0dc8511
      Peter Krempa 提交于
      The linux kernel recently added support for paravirtual spinlock
      handling to avoid performance regressions on overcomitted hosts. This
      feature needs to be turned in the hypervisor so that the guest OS is
      notified about the possible support.
      
      This patch adds a new feature "paravirt-spinlock" to the XML and
      supporting code to enable the "kvm_pv_unhalt" pseudo CPU feature in
      qemu.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1008989
      e0dc8511
    • P
      conf: Refactor storing and usage of feature flags · de7b5faf
      Peter Krempa 提交于
      Currently we were storing domain feature flags in a bit field as the
      they were either enabled or disabled. New features such as paravirtual
      spinlocks however can be tri-state as the default option may depend on
      hypervisor version.
      
      To allow storing tri-state feature state in the same place instead of
      having to declare dedicated variables for each feature this patch
      refactors the bit field to an array.
      de7b5faf
  7. 07 11月, 2013 1 次提交
    • P
      conf: Refactor virDomainDiskSourcePoolDefParse · 6e037015
      Peter Krempa 提交于
      For some strange reason virDomainDiskSourcePoolDefParse accessed def of
      the disk and allocated the pool object in it. To avoid the need to carry
      over the disk definition object, refactor this function to return the
      allocated object instead.
      6e037015
  8. 01 11月, 2013 1 次提交
    • D
      Fix race in starting transient VMs · 89759301
      Daniel P. Berrange 提交于
      When starting a transient VM the first thing done is to check
      for duplicates. The check looks if there are any running VMs
      with the matching name/uuid. It explicitly allows there to
      be inactive VMs, so that a persistent VM can be temporarily
      booted with a different config.
      
      There is a race condition, however, where 2 or more clients
      try to create the same transient VM. The first client will
      cause a virDomainObjPtr to be added to the domain list, and
      it is inactive at this stage. The second client may then
      come along and see this inactive VM, and mistake it for a
      persistent VM.
      
      If the first VM fails to start its transient guest for any
      reason, then it'll remove the virDomainObjPtr from the list.
      The second client now has a virDomainObjPtr that it can try
      to boot, which libvirt no longer has a record of. The result
      can be a running QEMU process that is orphaned.
      
      It was also, however, possible for the virDomainObjPtr to be
      completely free'd which will cause libvirtd to crash in some
      scenarios.
      
      The fix is to only allow an existing inactive VM if it is
      marked as persistent.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      89759301
  9. 30 10月, 2013 1 次提交
  10. 16 10月, 2013 1 次提交
    • M
      domain_conf.c: Initialize arrVar and cntVar · da716da3
      Michal Privoznik 提交于
      Some ancient gcc fails to see the variables are initialized in a
      separate function and a false positive is produced:
      
      cc1: warnings being treated as errors
      conf/domain_conf.c: In function 'virDomainChrGetDomainPtrs':
      conf/domain_conf.c:10342: error: 'arrVar' may be used uninitialized in this function [-Wuninitialized]
      conf/domain_conf.c:10343: error: 'cntVar' may be used uninitialized in this function [-Wuninitialized]
      conf/domain_conf.c: In function 'virDomainChrInsert':
      conf/domain_conf.c:10362: error: 'arrPtr' may be used uninitialized in this function [-Wuninitialized]
      conf/domain_conf.c:10363: error: 'cntPtr' may be used uninitialized in this function [-Wuninitialized]
      conf/domain_conf.c: In function 'virDomainChrRemove':
      conf/domain_conf.c:10374: error: 'arrPtr' may be used uninitialized in this function [-Wuninitialized]
      conf/domain_conf.c:10375: error: 'cntPtr' may be used uninitialized in this function [-Wuninitialized]
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      da716da3
  11. 15 10月, 2013 3 次提交
    • P
      conf: Mark user provided strings in error messages when parsing XML · 59ae97b4
      Peter Krempa 提交于
      Use apostrophes to denote user provided option names when parsing the
      domain XML.
      59ae97b4
    • E
      maint: avoid 'const fooPtr' in domain_conf · d2467709
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up offenders in src/conf/domain_conf, and their fallout.
      
      Several things to note: virObjectLock() requires a non-const
      argument; if this were C++, we could treat the locking field
      as 'mutable' and allow locking an otherwise 'const' object, but
      that is a more invasive change, so I instead dropped attempts
      to be const-correct on domain lookup.  virXMLPropString and
      friends require a non-const xmlNodePtr - this is because libxml2
      is not a const-correct library.  We could make the src/util/virxml
      wrappers cast away const, but I figured it was easier to not
      try to mark xmlNodePtr as const.  Finally, virDomainDeviceDefCopy
      was a rather hard conversion - it calls virDomainDeviceDefPostParse,
      which in turn in the xen driver was actually modifying the domain
      outside of the current device being visited.  We should not be
      adding a device on the first per-device callback, but waiting until
      after all per-device callbacks are complete.
      
      * src/conf/domain_conf.h (virDomainObjListFindByID)
      (virDomainObjListFindByUUID, virDomainObjListFindByName)
      (virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
      const.
      (virDomainDeviceDefCopy): Use intended type.
      (virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
      (virDomainVideoDefaultType, virDomainVideoDefaultRAM)
      (virDomainChrGetDomainPtrs): Make const-correct.
      * src/conf/domain_conf.c (virDomainObjListFindByID)
      (virDomainObjListFindByUUID, virDomainObjListFindByName)
      (virDomainDeviceDefCopy, virDomainObjListAdd)
      (virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
      (virDomainHostdevSubsysPciOrigStatesDefParseXML)
      (virDomainHostdevSubsysPciDefParseXML)
      (virDomainHostdevSubsysScsiDefParseXML)
      (virDomainControllerModelTypeFromString)
      (virDomainTPMDefParseXML, virDomainTimerDefParseXML)
      (virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
      (virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
      (virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
      (virSysinfoParseXML, virDomainVideoAccelDefParseXML)
      (virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
      (virDomainRedirdevDefParseXML)
      (virDomainRedirFilterUsbDevDefParseXML)
      (virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
      (virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
      (virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
      (virDomainVideoDefaultType, virDomainHostdevAssignAddress)
      (virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
      (virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
      (virDomainSCSIDriveAddressIsUsed)
      (virDomainDriveAddressIsUsedByDisk)
      (virDomainDriveAddressIsUsedByHostdev): Fix fallout.
      * src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
      Likewise.
      * src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
      Likewise.
      * src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
      (qemuDomainDefaultNetModel): Likewise.
      * src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
      Likewise.
      * src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
      * src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
      (xenDomainDefPostParse): ...since per-device callback is not the
      time to be adding a device.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d2467709
    • E
      maint: fix awkward typing of virDomainChrGetDomainPtrs · f8fa2b3e
      Eric Blake 提交于
      virDomainChrGetDomainPtrs() required 4 levels of pointers (taking
      a parameter that will be used as an output variable to return the
      address of another variable that contains an array of pointers).
      This is rather complex to reason about, especially when outside
      of the domain_conf file, no other caller should be modifying
      the resulting array of pointers directly.  Changing the public
      signature gives something is easier to reason with, and actually
      make const-correct; which is important as it was the only function
      that was blocking virDomainDeviceDefCopy from treating its source
      as const.
      
      * src/conf/domain_conf.h (virDomainChrGetDomainPtrs): Use simpler
      types, and make const-correct for external users.
      * src/conf/domain_conf.c (virDomainChrGetDomainPtrs): Split...
      (virDomainChrGetDomainPtrsInternal): ...into an internal version
      that lets us modify terms, vs. external form that is read-only.
      (virDomainDeviceDefPostParseInternal, virDomainChrFind)
      (virDomainChrInsert): Adjust callers.
      * src/qemu/qemu_command.c (qemuGetNextChrDevIndex): Adjust caller.
      (qemuDomainDeviceAliasIndex): Make const-correct.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f8fa2b3e
  12. 09 10月, 2013 1 次提交
    • J
      LXC: Fix handling of RAM filesystem size units · 3f029fb5
      Ján Tomko 提交于
      Since 76b644c3 when the support for RAM filesystems was introduced,
      libvirt accepted the following XML:
      <source usage='1024' unit='KiB'/>
      
      This was parsed correctly and internally stored in bytes, but it
      was formatted as (with an extra 's'):
      <source usage='1024' units='KiB'/>
      When read again, this was treated as if the units were missing,
      meaning libvirt was unable to parse its own XML correctly.
      
      The usage attribute was documented as being in KiB, but it was not
      scaled if the unit was missing. Transient domains still worked,
      because this was balanced by an extra 'k' in the mount options.
      
      This patch:
      Changes the parser to use 'units' instead of 'unit', as the latter
      was never documented (fixing persistent domains) and some programs
      (libvirt-glib, libvirt-sandbox) already parse the 'units' attribute.
      
      Removes the extra 'k' from the tmpfs mount options, which is needed
      because now we parse our own XML correctly.
      
      Changes the default input unit to KiB to match documentation, fixing:
      https://bugzilla.redhat.com/show_bug.cgi?id=1015689
      3f029fb5
  13. 04 10月, 2013 1 次提交
    • C
      test: Implement snapshot create/delete/revert APIs · 390c06b6
      Cole Robinson 提交于
      Again stolen from qemu_driver.c, but dropping all the unneeded bits.
      This aims to copy all the current qemu validation checks since that's
      the most commonly used real driver, but some of the checks are
      completely artificial in the test driver.
      
      This only supports creation of internal snapshots for initial
      simplicity.
      390c06b6
  14. 26 9月, 2013 2 次提交
    • P
      conf: clean up virDomainChrSourceDefParseXML · 0dd948cb
      Peter Krempa 提交于
      Tweak some conditions and use correct typecasts in enums.
      0dd948cb
    • P
      conf: Don't crash on invalid chardev source definition of RNGs and other · 79552754
      Peter Krempa 提交于
      Since commit 297c99a5 an invalid source definition XML of a character
      device that is used as backend for RNG devices, smartcards and redirdevs
      causes crash of the daemon when parsing such a definition.
      
      The device types mentioned above are not a part of a regular character
      device but are backends for other types. Thus when parsing such device
      NULL is passed as the argument @chr_def. Later when checking the
      validity of the definition @chr_def was dereferenced when parsing a UNIX
      socket backend with missing path of the socket and crashed the daemon.
      
      Sample offending configuration:
        <devices>
        ...
          <rng model='virtio'>
            <backend model='egd' type='unix'>
              <source mode='bind' service='1024'/>
            </backend>
          </rng>
        </devices>
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1012196
      79552754
  15. 25 9月, 2013 5 次提交
  16. 24 9月, 2013 2 次提交
  17. 23 9月, 2013 1 次提交
    • P
      conf: Do better job when comparing features ABI compatibility · 5702c014
      Peter Krempa 提交于
      The ABI compatibility check for domain features didn't check the
      expanded HyperV and APIC EOI values, thus possibly allowing change in
      guest ABI.
      
      Add the check and use typecasted switch statement to warn developers
      when adding a new HyperV feature.
      5702c014
  18. 18 9月, 2013 1 次提交
    • D
      Allow <source> for type=block to have no dev · 4b5652d0
      Doug Goldstein 提交于
      Currently the XML parser already allows the following syntax:
        <disk type='block' device='cdrom'>
          <source startupPolicy='optional'/>
          <target dev='hda' bus='ide'/>
          <address type='drive' controller='0' bus='0' target='0' unit='0'/>
        </disk>
      
      But it if the dev value is NULL then it would not have the leading
      "<source ", resulting in invalid XML.
      4b5652d0
  19. 17 9月, 2013 6 次提交
    • A
      Add tftp protocol support for cdrom disk · 8ffe1d0c
      Aline Manera 提交于
      qemu/KVM also supports a tftp URL while specifying the cdrom ISO image.
      
      The xml should be as following:
      
          <disk type='network' device='cdrom'>
            <source protocol='tftp' name='/url/path'>
              <host name='host.name' port='69'/>
            </source>
          </disk>
      Signed-off-by: NAline Manera <alinefm@br.ibm.com>
      8ffe1d0c
    • A
      Add ftps protocol support for cdrom disk · 0f24393e
      Aline Manera 提交于
      The ftps protocol is another protocol supported by qemu/KVM while specifying
      the cdrom ISO image.
      
      The xml should be as following:
      
          <disk type='network' device='cdrom'>
            <source protocol='ftps' name='/url/path'>
              <host name='host.name' port='990'/>
            </source>
          </disk>
      Signed-off-by: NAline Manera <alinefm@br.ibm.com>
      0f24393e
    • A
      Add https protocol support for cdrom disk · d9dd9818
      Aline Manera 提交于
      The https protocol is also accepted by qemu/KVM when specifying the cdrom ISO
      image.
      
      The xml should be as following:
      
          <disk type='network' device='cdrom'>
            <source protocol='https' name='/url/path'>
              <host name='host.name' port='443'/>
            </source>
          </disk>
      Signed-off-by: NAline Manera <alinefm@br.ibm.com>
      d9dd9818
    • P
      conf: Avoid false positive of uninitialized variable use · 0d4f469c
      Peter Krempa 提交于
      GCC 4.8.0+ whines about variable "new" being uninitialized since
      commit 73bfac0e. This is a false positive as the
      xmlFreeNode(new) statement can be only reached if new was actually
      allocated successfully.
      
        CC       conf/libvirt_conf_la-domain_conf.lo
        conf/domain_conf.c: In function 'virDomainDefSetMetadata':
        conf/domain_conf.c:18650:24: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                     xmlFreeNode(new);
      
      Reported independently by John Ferlan and Michal Privoznik.
      0d4f469c
    • P
      conf: Don't corrupt metadata on OOM · 7655ed08
      Peter Krempa 提交于
      Eric Blake suggested that we could do a little better in case copying of
      the metadata to be set fails. With this patch, the old metadata is
      discarded after the new string is copied successfuly.
      7655ed08
    • P
      conf: allow to add XML metadata using the virDomainSetMetadata api · 73bfac0e
      Peter Krempa 提交于
      The functionality wasn't originally implemented. This patch adds the
      ability to modify domain's XML metadata using the API.
      73bfac0e