1. 02 12月, 2013 9 次提交
    • 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
      snapshot: conf: Fix NULL dereference when <driver> element is empty · 5a66c667
      Peter Krempa 提交于
      Consider the following valid snapshot XML as the <driver> element is
      allowed to be empty in the domainsnapshot.rng schema:
      
      $ cat snap.xml
      <domainsnapshot>
        <disks>
          <disk name='vda' snapshot='external'>
            <source file='/tmp/foo'/>
            <driver/>
          </disk>
        </disks>
      </domainsnapshot>
      
      produces the following error:
      
      $ virsh snapshot-create domain snap.xml
      error: internal error: unknown disk snapshot driver '(null)'
      
      The driver type is parsed as NULL from the XML as the attribute is not
      present and then directly used to produce the error message.
      
      With this patch the attempt to parse the driver type is skipped if not
      present to avoid changing the schema to forbid the empty driver element.
      5a66c667
    • P
      snapshot: conf: Use common parsing and formatting functions for source · 43f2ccdc
      Peter Krempa 提交于
      Disk source elements for snapshots were using separate code from our
      config parser. As snapshots can be stored on more than just regular
      files, we will need the universal parser to allow us to expose a variety
      of snapshot disk targets. This patch reuses the config parsers and
      formatters to do the job.
      
      This initial support only changes the code without any visible XML
      change.
      43f2ccdc
    • 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 virNWFilterDefParseXML() · 6c874c01
      Nehal J Wani 提交于
      While running nwfilterxml2xmltest, it was found that valgrind pointed out the
      following error...
      
      ==7466== 16 bytes in 1 blocks are definitely lost in loss record 26 of 90
      ==7466==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
          ==7466==    by 0x4C651AD: virAlloc (viralloc.c:142)
          ==7466==    by 0x4D0450D: virNWFilterDefParseNode (nwfilter_conf.c:2575)
          ==7466==    by 0x4D05D84: virNWFilterDefParse (nwfilter_conf.c:2647)
          ==7466==    by 0x401FDE: testCompareXMLToXMLHelper (nwfilterxml2xmltest.c:39)
          ==7466==    by 0x402DE1: virtTestRun (testutils.c:138)
          ==7466==    by 0x4018E9: mymain (nwfilterxml2xmltest.c:111)
          ==7466==    by 0x403482: virtTestMain (testutils.c:593)
          ==7466==    by 0x341F421A04: (below main) (libc-start.c:225)
      
      ...21 times, which are related to 21 tests in nwfilterxml2xmltest.c which sent
      EXPECT_WARN = false. There were two scenarios in virNWFilterDefParseXML(),
      when the variable 'entry' was malloc'ed, but not freed.
      6c874c01
    • 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 4 次提交
    • Y
      Fix three minor typos · 73a03e30
      Yuri Chornoivan 提交于
      73a03e30
    • E
      storage: add network-dir as new storage volume type · ecd881b7
      Eric Blake 提交于
      In the 'directory' and 'netfs' storage pools, a user can see
      both 'file' and 'dir' storage volume types, to know when they
      can descend into a subdirectory.  But in a network-based storage
      pool, such as the upcoming 'gluster' pool, we use 'network'
      instead of 'file', and did not have any counterpart for a
      directory until this patch.  Adding a new volume type
      'network-dir' is better than reusing 'dir', because it makes
      it clear that the only way to access 'network' volumes within
      that container is through the network mounting (leaving 'dir'
      for something accessible in the local file system).
      
      * include/libvirt/libvirt.h.in (virStorageVolType): Expand enum.
      * docs/formatstorage.html.in: Document it.
      * docs/schemasa/storagevol.rng (vol): Allow new value.
      * src/conf/storage_conf.c (virStorageVol): Use new value.
      * src/qemu/qemu_command.c (qemuBuildVolumeString): Fix client.
      * src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
      * tools/virsh-volume.c (vshVolumeTypeToString): Likewise.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemVolDelete): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ecd881b7
    • E
      storage: initial support for linking with libgfapi · 318ea3cb
      Eric Blake 提交于
      We support gluster volumes in domain XML, so we also ought to
      support them as a storage pool.  Besides, a future patch will
      want to take advantage of libgfapi to handle the case of a
      gluster device holding qcow2 rather than raw storage, and for
      that to work, we need a storage backend that can read gluster
      storage volume contents.  This sets up the framework.
      
      Note that the new pool is named 'gluster' to match a
      <disk type='network'><source protocol='gluster'> image source
      already supported in a <domain>; it does NOT match the
      <pool type='netfs'><source><target type='glusterfs'>,
      since that uses a FUSE mount to a local file name rather than
      a network name.
      
      This and subsequent patches have been tested against glusterfs
      3.4.1 (available on Fedora 19); there are likely bugs in older
      versions that may prevent decent use of gfapi, so this patch
      enforces the minimum version tested.  A future patch may lower
      the minimum.  On the other hand, I hit at least two bugs in
      3.4.1 that will be fixed in 3.5/3.4.2, where it might be worth
      raising the minimum: glfs_readdir is nicer to use than
      glfs_readdir_r [1], and glfs_fini should only return failure on
      an actual failure [2].
      
      [1] http://lists.gnu.org/archive/html/gluster-devel/2013-10/msg00085.html
      [2] http://lists.gnu.org/archive/html/gluster-devel/2013-10/msg00086.html
      
      * configure.ac (WITH_STORAGE_GLUSTER): New conditional.
      * m4/virt-gluster.m4: new file.
      * libvirt.spec.in (BuildRequires): Support gluster in spec file.
      * src/conf/storage_conf.h (VIR_STORAGE_POOL_GLUSTER): New pool
      type.
      * src/conf/storage_conf.c (poolTypeInfo): Treat similar to
      sheepdog and rbd.
      (virStoragePoolDefFormat): Don't output target for gluster.
      * src/storage/storage_backend_gluster.h: New file.
      * src/storage/storage_backend_gluster.c: Likewise.
      * po/POTFILES.in: Add new file.
      * src/storage/storage_backend.c (backends): Register new type.
      * src/Makefile.am (STORAGE_DRIVER_GLUSTER_SOURCES): Build new files.
      * src/storage/storage_backend.h (_virStorageBackend): Documet
      assumption.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      318ea3cb
    • E
      storage: expose volume meta-type in XML · 1b5c8d4c
      Eric Blake 提交于
      I got annoyed at having to use both 'virsh vol-list $pool --details'
      AND 'virsh vol-dumpxml $vol $pool' to learn if I had populated
      the volume correctly.  Since two-thirds of the data present in
      virStorageVolGetInfo() already appears in virStorageVolGetXMLDesc(),
      this just adds the remaining piece of information, as:
      
      <volume type='...'>
        ...
      </volume>
      
      * docs/formatstorage.html.in: Document new <volume type=...>.
      * docs/schemas/storagevol.rng (vol): Add it to RelaxNG.
      * src/conf/storage_conf.h (virStorageVolTypeToString): Declare.
      * src/conf/storage_conf.c (virStorageVolTargetDefFormat): Output
      the metatype.
      (virStorageVolDefParseXML): Parse it, for unit tests.
      * tests/storagevolxml2xmlout/vol-*.xml: Update tests to match.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b5c8d4c
  3. 22 11月, 2013 1 次提交
    • E
      storage: use valid XML for awkward volume names · 6cc4d6a3
      Eric Blake 提交于
      $ touch /var/lib/libvirt/images/'a<b>c'
      $ virsh pool-refresh default
      $ virsh vol-dumpxml 'a<b>c' default | head -n2
      <volume>
        <name>a<b>c</name>
      
      Oops.  That's not valid XML.  And when we fix the XML
      generation, it fails RelaxNG validation.
      
      I'm also tired of seeing <key>(null)</key> in the example
      output for volume xml; while we used NULLSTR() to avoid
      a NULL deref rather than relying on glibc's printf
      extension behavior, it's even better if we avoid the issue
      in the first place.  But this requires being careful that
      we don't invalidate any storage backends that were relying
      on key being unassigned during virStoragVolCreateXML[From].
      
      I would have split this into two patches (one for escaping,
      one for avoiding <key>(null)</key>), but since they both
      end up touching a lot of the same test files, I ended up
      merging it into one.
      
      Note that this patch allows pretty much any volume name
      that can appear in a directory (excluding . and .. because
      those are special), but does nothing to change the current
      (unenforced) RelaxNG claim that pool names will consist
      only of letters, numbers, _, -, and +.  Tightening the C
      code to match RelaxNG patterns and/or relaxing the grammar
      to match the C code for pool names is a task for another
      day (but remember, we DID recently tighten C code for
      domain names to exclude a leading '.').
      
      * src/conf/storage_conf.c (virStoragePoolSourceFormat)
      (virStoragePoolDefFormat, virStorageVolTargetDefFormat)
      (virStorageVolDefFormat): Escape user-controlled strings.
      (virStorageVolDefParseXML): Parse key, for use in unit tests.
      * src/storage/storage_driver.c (storageVolCreateXML)
      (storageVolCreateXMLFrom): Ensure parsed key doesn't confuse
      volume creation.
      * docs/schemas/basictypes.rng (volName): Relax definition.
      * tests/storagepoolxml2xmltest.c (mymain): Test it.
      * tests/storagevolxml2xmltest.c (mymain): Likewise.
      * tests/storagepoolxml2xmlin/pool-dir-naming.xml: New file.
      * tests/storagepoolxml2xmlout/pool-dir-naming.xml: Likewise.
      * tests/storagevolxml2xmlin/vol-file-naming.xml: Likewise.
      * tests/storagevolxml2xmlout/vol-file-naming.xml: Likewise.
      * tests/storagevolxml2xmlout/vol-*.xml: Fix fallout.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6cc4d6a3
  4. 21 11月, 2013 2 次提交
    • 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
    • E
      maint: fix comma style issues: nwfilter · f5690336
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/nwfilter/nwfilter_ebiptables_driver.c: Consistently use
      commas.
      * src/nwfilter/nwfilter_gentech_driver.c: Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c: Likewise.
      * src/conf/nwfilter_conf.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f5690336
  5. 15 11月, 2013 1 次提交
  6. 12 11月, 2013 3 次提交
  7. 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
  8. 08 11月, 2013 3 次提交
  9. 07 11月, 2013 2 次提交
  10. 04 11月, 2013 1 次提交
  11. 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
  12. 31 10月, 2013 2 次提交
    • E
      storage: use correct type for array count · 41183cf7
      Eric Blake 提交于
      Using size_t counts will let us use VIR_APPEND_ELEMENT and friends.
      
      * src/conf/storage_conf.h (_virStoragePoolObjList)
      (_virStorageVolDefList): Track list sizes with size_t.
      * src/storage/storage_backend_rbd.c
      (virStorageBackendRBDRefreshPool): Fix type fallout.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      41183cf7
    • E
      maint: avoid further typedef accidents · fb861352
      Eric Blake 提交于
      To make it easier to forbid future attempts at a confusing typedef
      name ending in Ptr that isn't actually a pointer, insist that we
      follow our preferred style of 'typedef foo *fooPtr'.
      
      * cfg.mk (sc_forbid_const_pointer_typedef): Enforce consistent
      style, to prevent issue fixed in previous storage patch.
      * src/conf/capabilities.h (virCapsPtr): Fix offender.
      * src/security/security_stack.c (virSecurityStackItemPtr):
      Likewise.
      * tests/qemucapabilitiestest.c (testQemuDataPtr): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fb861352
  13. 30 10月, 2013 1 次提交
  14. 29 10月, 2013 1 次提交
    • G
      capabilities: add baselabel per sec driver/virt type to secmodel · b51038a4
      Giuseppe Scrivano 提交于
      Expand the "secmodel" XML fragment of "host" with a sequence of
      baselabel's which describe the default security context used by
      libvirt with a specific security model and virtualization type:
      
      <secmodel>
        <model>selinux</model>
        <doi>0</doi>
        <baselabel type='kvm'>system_u:system_r:svirt_t:s0</baselabel>
        <baselabel type='qemu'>system_u:system_r:svirt_tcg_t:s0</baselabel>
      </secmodel>
      <secmodel>
        <model>dac</model>
        <doi>0</doi>
        <baselabel type='kvm'>107:107</baselabel>
        <baselabel type='qemu'>107:107</baselabel>
      </secmodel>
      
      "baselabel" is driver-specific information, e.g. in the DAC security
      model, it indicates USER_ID:GROUP_ID.
      Signed-off-by: NGiuseppe Scrivano <gscrivan@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b51038a4
  15. 22 10月, 2013 1 次提交
  16. 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
  17. 15 10月, 2013 6 次提交
    • 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 conf · 539a9fae
      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 remaining offenders in src/conf, and their fallout.
      
      * src/conf/snapshot_conf.h (virDomainSnapshotAssignDef)
      (virDomainSnapshotFindByName): Drop attempt at const.
      * src/conf/interface_conf.h (virInterfaceObjIsActive)
      (virInterfaceDefFormat): Use intended type.
      (virInterfaceFindByMACString, virInterfaceFindByName)
      (virInterfaceAssignDef, virInterfaceRemove): Drop attempt at
      const.
      * src/conf/network_conf.h (virNetworkObjIsActive)
      (virNetworkDefFormat, virNetworkDefForwardIf)
      (virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
      (virNetworkIpDefNetmask): Use intended type.
      (virNetworkFindByUUID, virNetworkFindByName, virNetworkAssignDef)
      (virNetworkObjAssignDef, virNetworkRemoveInactive)
      (virNetworkBridgeInUse, virNetworkSetBridgeName)
      (virNetworkAllocateBridge): Drop attempt at const.
      * src/conf/netdev_vlan_conf.h (virNetDevVlanFormat): Make
      const-correct.
      * src/conf/node_device_conf.h (virNodeDeviceHasCap)
      (virNodeDeviceDefFormat): Use intended type.
      (virNodeDeviceFindByName, virNodeDeviceFindBySysfsPath)
      (virNodeDeviceAssignDef, virNodeDeviceObjRemove)
      (virNodeDeviceGetParentHost): Drop attempt at const.
      * src/conf/secret_conf.h (virSecretDefFormat): Use intended type.
      * src/conf/snapshot_conf.c (virDomainSnapshotAssignDef)
      (virDomainSnapshotFindByName): Fix fallout.
      * src/conf/interface_conf.c (virInterfaceBridgeDefFormat)
      (virInterfaceBondDefFormat, virInterfaceVlanDefFormat)
      (virInterfaceProtocolDefFormat, virInterfaceDefDevFormat)
      (virInterfaceDefFormat, virInterfaceFindByMACString)
      (virInterfaceFindByName, virInterfaceAssignDef)
      (virInterfaceRemove): Likewise.
      * src/conf/network_conf.c
      (VIR_ENUM_IMPL, virNetworkFindByName, virNetworkObjAssignDef)
      (virNetworkAssignDef, virNetworkRemoveInactive)
      (virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
      (virNetworkIpDefNetmask, virNetworkDHCPHostDefParseXML)
      (virNetworkIpDefFormat, virNetworkRouteDefFormat)
      (virPortGroupDefFormat, virNetworkForwardNatDefFormat)
      (virNetworkDefFormatInternal, virNetworkBridgeInUse)
      (virNetworkAllocateBridge, virNetworkSetBridgeName)
      (virNetworkDNSDefFormat, virNetworkDefFormat): Likewise.
      * src/conf/netdev_vlan_conf.c (virNetDevVlanFormat): Likewise.
      * src/conf/node_device_conf.c (virNodeDeviceHasCap)
      (virNodeDeviceFindBySysfsPath, virNodeDeviceFindByName)
      (virNodeDeviceAssignDef, virNodeDeviceObjRemove)
      (virNodeDeviceDefFormat, virNodeDeviceGetParentHost): Likewise.
      * src/conf/secret_conf.c (virSecretDefFormatUsage)
      (virSecretDefFormat): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      539a9fae
    • 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
    • E
      maint: avoid 'const fooPtr' in nwfilter files · 1b7ec657
      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 nwfilter code.
      
      This patch does nothing about the stupidity evident in having
      __virNWFilterInstantiateFilter, _virNWFilterInstantiateFilter,
      and virNWFilterInstantiateFilter, which differ only by leading
      underscores, and which infringes on the namespace reserved to
      the implementation - that would need to be a separate cleanup.
      
      * src/nwfilter/nwfilter_dhcpsnoop.h (virNWFilterDHCPSnoopReq): Use
      intended type.
      * src/nwfilter/nwfilter_gentech_driver.h
      (virNWFilterInstantiateFilter)
      (virNWFilterUpdateInstantiateFilter)
      (virNWFilterInstantiataeFilterLate, virNWFilterTeardownFilter)
      (virNWFilterCreateVarHashmap): Likewise.
      * src/nwfilter/nwfilter_learnipaddr.h (virNWFilterLearnIPAddress):
      Likewise.
      * src/conf/nwfilter_conf.h (virNWFilterApplyBasicRules)
      (virNWFilterApplyDHCPOnlyRules): Likewise.
      (virNWFilterDefFormat): Make const-correct.
      * src/conf/nwfilter_params.h (virNWFilterVarValueCopy)
      (virNWFilterVarValueGetSimple, virNWFilterVarValueGetCardinality)
      (virNWFilterVarValueEqual, virNWFilterVarAccessEqual)
      (virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
      (virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
      (virNWFilterVarAccessIsAvailable)
      (virNWFilterVarCombIterGetVarValue): Use intended type.
      (virNWFilterVarValueGetNthValue): Make const-correct.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
      (virNWFilterSnoopIFKeyFMT, virNWFilterDHCPSnoopReq)
      (virNWFilterSnoopPruneIter, virNWFilterSnoopRemAllReqIter)
      (virNWFilterDHCPSnoopReq): Fix fallout.
      * src/nwfilter/nwfilter_gentech_driver.c
      (virNWFilterVarHashmapAddStdValues, virNWFilterCreateVarHashmap)
      (virNWFilterInstantiate, __virNWFilterInstantiateFilter)
      (_virNWFilterInstantiateFilter, virNWFilterInstantiateFilterLate)
      (virNWFilterInstantiateFilter)
      (virNWFilterUpdateInstantiateFilter)
      (virNWFilterRollbackUpdateFilter, virNWFilterTeardownFilter):
      Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnIPAddress):
      Likewise.
      * src/conf/nwfilter_params.c (virNWFilterVarValueCopy)
      (virNWFilterVarValueGetSimple)
      (virNWFilterVarValueGetCardinality, virNWFilterVarValueEqual)
      (virNWFilterVarCombIterAddVariable)
      (virNWFilterVarCombIterGetVarValue, virNWFilterVarValueCompare)
      (virNWFilterFormatParamAttributes, virNWFilterVarAccessEqual)
      (virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
      (virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
      (virNWFilterVarAccessGetIntIterId)
      (virNWFilterVarAccessIsAvailable)
      (virNWFilterVarValueGetNthValue): Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c (ebtablesApplyBasicRules)
      (ebtablesApplyDHCPOnlyRules, ebiptablesRuleOrderSort)
      (ebiptablesRuleOrderSortPtr): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterDefEqual)
      (virNWFilterDefFormat): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b7ec657
    • E
      maint: avoid 'const fooPtr' in cpu files · d694ae0c
      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/cpu.
      
      * src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
      (cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
      (cpuHasFeature): Use intended type.
      * src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
      Likewise.
      (virCPUDefParseXML): Drop const.
      * src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
      Fix fallout.
      * src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
      (x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
      (x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
      * src/cpu/cpu_s390.c (s390Decode): Likewise.
      * src/cpu/cpu_arm.c (ArmDecode): Likewise.
      * src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
      (ppcUpdate): Likewise.
      * src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
      (virCPUDefParseXML): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d694ae0c