1. 16 7月, 2014 18 次提交
    • E
      util: forbid freeing const pointers · a0b5ace2
      Eric Blake 提交于
      Now that we've finally fixed all the violators, it's time to
      enforce that any pointer to a const object is never freed (it
      is aliasing some other memory, where the non-const original
      should be freed instead).  Alas, the code still needs a normal
      vs. Coverity version, but at least we are still guaranteeing
      that the macro call evaluates its argument exactly once.
      
      I verified that we still get the following compiler warnings,
      which in turn halts the build thanks to -Werror on gcc (hmm,
      gcc 4.8.3's placement of the ^ for ?: type mismatch is a bit
      off, but that's not our problem):
      
          int oops1 = 0;
          VIR_FREE(oops1);
          const char *oops2 = NULL;
          VIR_FREE(oops2);
          struct blah { int dummy; } oops3;
          VIR_FREE(oops3);
      
      util/virauthconfig.c:159:35: error: pointer/integer type mismatch in conditional expression [-Werror]
           VIR_FREE(oops1);
                                         ^
      util/virauthconfig.c:161:5: error: passing argument 1 of 'virFree' discards 'const' qualifier from pointer target type [-Werror]
           VIR_FREE(oops2);
           ^
      In file included from util/virauthconfig.c:28:0:
      util/viralloc.h:79:6: note: expected 'void *' but argument is of type 'const void *'
       void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
            ^
      util/virauthconfig.c:163:35: error: type mismatch in conditional expression
           VIR_FREE(oops3);
                                         ^
      
      * src/util/viralloc.h (VIR_FREE): No longer cast away const.
      * src/xenapi/xenapi_utils.c (xenSessionFree): Work around bogus
      header.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a0b5ace2
    • C
      add nocow test case · 0b0c641b
      Chunyan Liu 提交于
      Add file in storagevolxml2xmlin and storagevolxml2xmlout, let
      storagevolxml2xmltest and storagevolschematest cover 'nocow'.
      Add test case to storagevolxml2argvtest to cover 'nocow'.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      0b0c641b
    • C
      storagevol: add nocow to vol xml · a9fd30e6
      Chunyan Liu 提交于
      Add 'nocow' to storage volume xml so that user can have an option
      to set NOCOW flag to the newly created volume. It's useful on btrfs
      file system to enhance performance.
      
      Btrfs has low performance when hosting VM images, even more when the guest
      in those VM are also using btrfs as file system. One way to mitigate this
      bad performance is to turn off COW attributes on VM files. Generally, there
      are two ways to turn off COW on btrfs: a) by mounting fs with nodatacow,
      then all newly created files will be NOCOW. b) per file. Add the NOCOW file
      attribute. It could only be done to empty or new files.
      
      This patch tries the second way, according to 'nocow' option, it could set
      NOCOW flag per file:
      for raw file images, handle 'nocow' in libvirt code; for non-raw file images,
      pass 'nocow=on' option to qemu-img, and let qemu-img to handle that (requires
      qemu-img version >= 2.1).
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      a9fd30e6
    • M
      Fix const correctness · 607806f8
      Michal Privoznik 提交于
      In many places we define a variable as a 'const char *' when in fact
      we modify it just a few lines below. Or even free it. We should not do
      that.
      
      There's one exception though, in xenSessionFree() xenapi_utils.c. We
      are freeing the xen_session structure which is defined in
      xen/api/xen_common.h public header. The structure contains session_id
      which is type of 'const char *' when in fact it should have been just
      'char *'. So I'm leaving this unmodified, just noticing the fact in
      comment.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      607806f8
    • P
      storage: fs: Don't fail volume update if backing store isn't accessible · 70120e2f
      Peter Krempa 提交于
      When the backing store of a volume wasn't accessible while updating the
      volume definition the call would fail altogether. In cases where we
      currently (incorrectly) treat remote backing stores as local one this
      might lead to strange errors.
      
      Ignore the opening errors until we figure out how to track proper volume
      metadata.
      70120e2f
    • P
      storage: fs: Properly parse backing store info · dc294357
      Peter Krempa 提交于
      Use the backing store parser to properly create the information about a
      volume's backing store. Unfortunately as the storage driver isn't
      prepared to allow volumes backed by networked filesystems add a
      workaround that will avoid changing the XML output.
      dc294357
    • P
      storage: fs: Process backing store data in virStorageBackendProbeTarget · cd4d5475
      Peter Krempa 提交于
      Move the processing of the backend metadata directly to the helper
      instead of passing it through arguments to the function.
      cd4d5475
    • P
      storage: backend: fs: Touch up coding style · 9f20d6a5
      Peter Krempa 提交于
      virStorageBackendFileSystemRefresh() used "cleanup" label just for error
      exits and didn't meet libvirt's standard for braces in one case.
      9f20d6a5
    • P
      storage: Track backing store of a volume in the target struct · 15213d1e
      Peter Krempa 提交于
      As we have a nested pointer for storing the backing store of a volume
      there's no need to store it in a separate struct.
      15213d1e
    • P
      c861750e
    • J
      Fix assignment of comparison against zero · 3103a977
      Ján Tomko 提交于
      Assign the value we're comparing:
      (val = func()) < 0
      instead of assigning the comparison value:
      (val = func() < 0)
      
      Both were introduced along with the code,
      the TLS tests by commit bd789dff in 0.9.4
      net events by commit de87691f in 1.2.2.
      
      Note that the event id type fix is a no-op:
      vshNetworkEventIdTypeFromString can only return
      -1 (failure) and the event is never used or
      0 (the only possible event) and the value of 0 < 0 is still 0.
      3103a977
    • J
      Fix error on fs pool build failure · d7dedc36
      Ján Tomko 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1119592
      
      Introduced by commit 62927dd8 v0.7.6.
      d7dedc36
    • E
      spec: fix invalid syntax · 13228b85
      Eric Blake 提交于
      Commit 20e01504 broke 'make rpm':
      
      error: line 540: Unknown tag:     %elif 020 >= 12 || 0 >= 6
      
      Apparently, even though shell has elif so that you can do a chain
      of conditionals, the rpm spec file does not, and you have to nest
      things instead.
      
      * libvirt.spec.in: Convert %elif to proper nested %if.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      13228b85
    • C
      Rework lxc apparmor profile · 9265f8ab
      Cédric Bosdonnat 提交于
      Rework the apparmor lxc profile abstraction to mimic ubuntu's container-default.
      This profile allows quite a lot, but strives to restrict access to
      dangerous resources.
      
      Removing the explicit authorizations to bash, systemd and cron files,
      forces them to keep the lxc profile for all applications inside the
      container. PUx permissions where leading to running systemd (and others
      tasks) unconfined.
      
      Put the generic files, network and capabilities restrictions directly
      in the TEMPLATE.lxc: this way, users can restrict them on a per
      container basis.
      9265f8ab
    • R
      Implement interface stats for BSD · 61bbdbb9
      Roman Bogorodskiy 提交于
      61bbdbb9
    • R
      util: virstatslinux: make more generic · 5559a8b8
      Roman Bogorodskiy 提交于
      Rename linuxDomainInterfaceStats to virNetInterfaceStats in order
      to allow adding platform specific implementations without
      making consumer worrying about specific implementation to be used.
      
      Also, rename util/virstatslinux.c to util/virstats.c so placing
      other platform specific implementations into this file don't
      look unexpected from the file name.
      5559a8b8
    • C
      libxl: fix return value error Attach|DetachDeviceFlags · 2f97ea32
      Chunyan Liu 提交于
      Code logic in libxlDomainAttachDeviceFlags and libxlDomainDetachDeviceFlags
      is wrong with return value in error cases.
      
      'ret' was being set to 0 if 'flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG' was
      false. Then if something like virDomainDeviceDefParse() failed in the
      VIR_DOMAIN_DEVICE_MODIFY_LIVE logic, the error would be reported but the
      function would return success.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      2f97ea32
    • C
      libxl: support hotplug of <interface> · b0d24540
      Chunyan Liu 提交于
      Add code to support attach/detaching a network device.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      b0d24540
  2. 15 7月, 2014 4 次提交
    • C
      libxl: add HOSTDEV type in libxlDomainDetachDeviceConfig · 232cf2a4
      Chunyan Liu 提交于
      Missing HOSTDEV type in libxlDomainDetachDeviceConfig. Add it.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      232cf2a4
    • J
      spec: Update polkit dependencies for CVE-2013-4311 · 20e01504
      Jiri Denemark 提交于
      Use secured polkit on distros which provide it. However, RHEL-6 will
      still allow for older polkit-0.93 rather than forcing polkit-0.96-5
      which is not available in all RHEL-6 releases.
      20e01504
    • P
      qemu: blockcopy: Initialize correct source structure · 95d6aff7
      Peter Krempa 提交于
      4cc1f1a0 introduced a crash when doing a
      block copy as virStorageSourceInitChainElement was called on
      "disk->mirror" that is still NULL at that point instead of "mirror"
      which temporarily holds the mirror source struct until it's fully
      initialized. This resulted into a crash as a NULL was dereferenced.
      
      Reported by: Shanzi Yu <shyu@redhat.com>
      95d6aff7
    • J
      GetBlockInfo: Use the correct path to qemuOpenFile · 54d4619c
      John Ferlan 提交于
      Commit id '3ea661de' refactored the code to use the 'disk->src->path'
      instead of getting the path from virDomainDiskGetSource().  The one
      call to qemuOpenFile() didn't use the disk source path, rather it used
      the path as passed from the caller (in this case 'vda') - this caused
      a failure with the virt-test/tp-libvirt as follows:
      
      $ virsh domblkinfo virt-tests-vm1 vda
      error: cannot stat file '/home/virt-test/shared/data/images/jeos-20-64.qcow2': Bad file descriptor
      
      $
      54d4619c
  3. 14 7月, 2014 8 次提交
    • E
      capabilities: use bool instead of int · 58156f39
      Eric Blake 提交于
      While preparing to add a capability for active commit, I noticed
      that the existing code was abusing int for boolean values.
      
      * src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost)
      (virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve
      types.
      * src/conf/capabilities.c (virCapabilitiesNew)
      (virCapabilitiesAddGuestFeature): Adjust signature.
      * src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update
      clients.
      * src/esx/esx_driver.c (esxCapsInit): Likewise.
      * src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise.
      * src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise.
      * src/openvz/openvz_conf.c (openvzCapsInit): Likewise.
      * src/parallels/parallels_driver.c (parallelsBuildCapabilities):
      Likewise.
      * src/phyp/phyp_driver.c (phypCapsInit): Likewise.
      * src/qemu/qemu_capabilities.c (virQEMUCapsInit)
      (virQEMUCapsInitGuestFromBinary): Likewise.
      * src/security/virt-aa-helper.c (get_definition): Likewise.
      * src/test/test_driver.c (testBuildCapabilities): Likewise.
      * src/uml/uml_conf.c (umlCapsInit): Likewise.
      * src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise.
      * src/vmware/vmware_conf.c (vmwareCapsInit): Likewise.
      * src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities):
      Likewise.
      * src/xenapi/xenapi_driver.c (getCapsObject): Likewise.
      * tests/qemucaps2xmltest.c (testGetCaps): Likewise.
      * tests/testutils.c (virTestGenericCapsInit): Likewise.
      * tests/testutilslxc.c (testLXCCapsInit): Likewise.
      * tests/testutilsqemu.c (testQemuCapsInit): Likewise.
      * tests/testutilsxen.c (testXenCapsInit): Likewise.
      * tests/vircaps2xmltest.c (buildVirCapabilities): Likewise.
      * tests/vircapstest.c (buildNUMATopology): Likewise.
      * tests/vmx2xmltest.c (testCapsInit): Likewise.
      * tests/xml2vmxtest.c (testCapsInit): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      58156f39
    • E
      docs: mention more about older capability feature bits · 06cf86e9
      Eric Blake 提交于
      Our documentation for features was rather sparse; this fleshes out
      more of the details for other existing capabilities (and cost me
      some time trawling git history).
      
      * docs/formatcaps.html.in: Document it feature bits.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      06cf86e9
    • C
      openvswitch: Delete port if it exists while adding a new one · 33445ce8
      Chunhe Li 提交于
      If the openvswitch service is stopped, and is followed by destroying a
      VM, the openvswitch bridge translates into a state where it doesn't
      recover the port configuration. While it successfully fetches data
      from the internal DB, since the corresponding virtual interface does
      not exists anymore the whole recovery process fails leaving restarted
      VM with inability to connect to the bridge. The following set of
      commands will trigger the problem:
      
      virsh start vm
      service openvswitch-switch stop
      virsh destroy vm
      service openvswitch-switch start
      virsh start vm
      Signed-off-by: NChunhe Li <lichunhe@huawei.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      33445ce8
    • J
      virseclabel: Resolve Coverity FORWARD_NULL issue · 1c89f6eb
      John Ferlan 提交于
      Resolve issue introduced by commit id '13adf1b2'
      1c89f6eb
    • M
      virSecurityLabelDefParseXML: Rework · da78351b
      Michal Privoznik 提交于
      Instead of allocating the virSecurityLabelDef structure ourselves, we
      can utilize virSecurityLabelDefNew which even sets the default values
      for us.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      da78351b
    • M
      conf: Always format seclabel's model · 99c8d2e8
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1113860
      
      We've always done that. Well, until 990e46c4. Point is, if we don't
      format model, we may lose a domain on libvirtd restart. If the
      seclabel is implicit however, we should skip it's formatting.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      99c8d2e8
    • P
      doc: Be more specific about semantics of _REUSE_EXT flag · 6f04fb15
      Peter Krempa 提交于
      Snapshots and block-copy have a flag that forces qemu to re-use existing
      file. Our docs weren't exactly clear on what the existing file should
      contain for this to actually work.
      
      Re-word the docs a bit to state that the file needs to be pre-created in
      the desired format and the backing chain metadata needs to be set prior
      to handing it over to qemu.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1084360
      6f04fb15
    • P
      doc: Document that snapshot name of block-backed disk isn't autogenerated · 500f80a5
      Peter Krempa 提交于
      Libvirt generates external snapshot target file names for file backed
      storage but not for block backed storage. Document the limitation.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1032363
      500f80a5
  4. 12 7月, 2014 3 次提交
  5. 11 7月, 2014 6 次提交
  6. 10 7月, 2014 1 次提交
    • J
      check for cfg->spiceTLS earlier in qemuProcessSPICEAllocatePorts · b02fca79
      Ján Tomko 提交于
      This saves a few lines of code and catches the error when:
      <spice autoport ='yes' defaultMode='any' ..>
        <channel name='main' mode='secure'/>
      </spice>
      is specified with spice_tls = 0 in qemu.conf.
      
      Instead of this error in qemuBuildGraphicsSPICECommandLine:
      error: unsupported configuration: spice secure channels set in XML
      configuration, but TLS port is not provided
      
      an error is reported in qemuProcessSPICEAllocatePorts:
      error: unsupported configuration: Auto allocation of spice TLS port
      requested but spice TLS is disabled in qemu.conf
      
      Inspired by:
      https://www.redhat.com/archives/libvir-list/2014-June/msg01408.html
      b02fca79