1. 16 12月, 2015 1 次提交
  2. 29 8月, 2015 1 次提交
  3. 23 1月, 2015 2 次提交
  4. 23 12月, 2014 1 次提交
  5. 18 9月, 2014 1 次提交
  6. 08 8月, 2014 1 次提交
    • E
      blockjob: fix use-after-free in blockcopy · 9617e31b
      Eric Blake 提交于
      Commit febf84c2 tried to delay in-memory modification of the actual
      domain disk structure until after the qemu event was received.
      However, I missed that the code for block pivot had been temporarily
      setting disk->src = disk->mirror prior to the qemu command, in order
      to label the backing chain of a reused external blockcopy disk;
      and calls into qemu while still in that state before finally undoing
      things at the cleanup label.  Since the qemu event handler then does:
       virStorageSourceFree(disk->src);
       disk->src = disk->mirror;
      we have the sad race that a fast enough qemu event can cause a leak of
      the original disk->src, as well as a use-after-free of the disk->mirror
      contents, bad enough to crash libvirtd in some of my test runs, even
      though the common case of the qemu event being much later won't trip
      the race.
      
      I'll go wear the brown paper bag of shame, for introducing a crasher
      in between rc1 and rc2 of the freeze for 1.2.7 :(  My only
      consolation is that virDomainBlockJobAbort requires the domain:write
      ACL, so it is not a CVE.
      
      The valgrind report when the race occurs looks like:
      
      ==25612== Invalid read of size 4
      ==25612==    at 0x50E7C90: virStorageSourceGetActualType (virstoragefile.c:1948)
      ==25612==    by 0x209C0B18: qemuDomainDetermineDiskChain (qemu_domain.c:2473)
      ==25612==    by 0x209D7F6A: qemuProcessHandleBlockJob (qemu_process.c:1087)
      ==25612==    by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)
      ...
      ==25612==  Address 0xe4b5610 is 0 bytes inside a block of size 200 free'd
      ==25612==    at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==25612==    by 0x50839E9: virFree (viralloc.c:582)
      ==25612==    by 0x50E7E51: virStorageSourceFree (virstoragefile.c:2015)
      ==25612==    by 0x209D7EFF: qemuProcessHandleBlockJob (qemu_process.c:1073)
      ==25612==    by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)
      
      * src/qemu/qemu_driver.c (qemuDomainBlockPivot): Don't corrupt
      disk->src, and only label chain for blockcopy.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 265680c5)
      9617e31b
  7. 06 8月, 2014 1 次提交
  8. 30 7月, 2014 4 次提交
    • E
      blockcommit: turn on active commit · cfb16b8e
      Eric Blake 提交于
      With this in place, I can (finally!) now do:
      
      virsh blockcommit $dom vda --shallow --verbose --pivot
      
      and watch qemu shorten the backing chain by one, followed by
      libvirt automatically updating the dumpxml output, effectively
      undoing the work of virsh snapshot-commit --no-metadata --disk-only.
      Commit is SOOOO much faster than blockpull, when I'm still fairly
      close in time to when the temporary qcow2 wrapper file was created
      via a snapshot operation!
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
      commit.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cfb16b8e
    • E
      blockcommit: track job type in xml · 232a31be
      Eric Blake 提交于
      A future patch is going to wire up qemu active block commit jobs;
      but as they have similar events and are canceled/pivoted in the
      same way as block copy jobs, it is easiest to track all bookkeeping
      for the commit job by reusing the <mirror> element.  This patch
      adds domain XML to track which job was responsible for creating a
      mirroring situation, and adds a job='copy' attribute to all
      existing uses of <mirror>.  Along the way, it also massages the
      qemu monitor backend to read the new field in order to generate
      the correct type of libvirt job (even though it requires a
      future patch to actually cause a qemu event that can be reported
      as an active commit).  It also prepares to update persistent XML
      to match changes made to live XML when a copy completes.
      
      * docs/schemas/domaincommon.rng: Enhance schema.
      * docs/formatdomain.html.in: Document it.
      * src/conf/domain_conf.h (_virDomainDiskDef): Add a field.
      * src/conf/domain_conf.c (virDomainBlockJobType): String conversion.
      (virDomainDiskDefParseXML): Parse job type.
      (virDomainDiskDefFormat): Output job type.
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Distinguish
      active from regular commit.
      * src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set job type.
      (qemuDomainBlockPivot, qemuDomainBlockJobImpl): Clean up job type
      on completion.
      * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
      Update tests.
      * tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.
      * tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml: New
      file.
      * tests/qemuxml2xmltest.c (mymain): Drive new test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      232a31be
    • E
      blockjob: properly track blockcopy xml changes on disk · febf84c2
      Eric Blake 提交于
      We were not directly saving the domain XML to file after starting
      or finishing a blockcopy.  Without the startup write, a libvirtd
      restart in the middle of a copy job would forget that the job was
      underway.  Then at pivot, we were indirectly writing new XML in
      reaction to events that occur as we stop and restart the guest CPUs.
      But there was a race: since pivot is an async action, it is possible
      that libvirtd is restarted before the pivot completes, so if XML
      changes during the event, that change was not written.  The original
      blockcopy code cleared out the <mirror> element prior to restarting
      the CPUs, but this is also a race, observed if a user does an async
      pivot and a dumpxml before the event occurs.  Furthermore, this race
      will interfere with active commit in a future patch, because that
      code will rely on the <mirror> element at the time of the qemu event
      to determine whether to inform the user of a normal commit or an
      active commit.
      
      Fix things by saving state any time we modify live XML, while
      delaying XML disk modifications until after the event completes.  We
      still need a to teach libvirtd restarts to examine all existing
      <mirror> elements to see if the job completed in the meantime (that
      is, if libvirtd misses the event, the updated state still needs to be
      updated in live XML), but that will be a later patch, in part because
      we also need to to start taking advantage of newer qemu's ability to
      keep the job around after completion rather than the current usage
      where the job disappears both on error and on success.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCopy): Track XML change
      on disk.
      (qemuDomainBlockJobImpl, qemuDomainBlockPivot): Move job-end XML
      rewrites...
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): ...here.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      febf84c2
    • E
      blockcopy: add more XML for state tracking · 9a212d67
      Eric Blake 提交于
      Doing a blockcopy operation across a libvirtd restart is not very
      robust at the moment.  In particular, we are clearing the <mirror>
      element prior to telling qemu to finish the job.  Also, thanks to the
      ability to request async completion, the user can easily regain
      control prior to qemu actually finishing the effort, and they should
      be able to poll the domain XML to see if the job is still going.
      
      A future patch will fix things to actually wait until qemu is done
      before modifying the XML to reflect the job completion.  But since
      qemu issues identical BLOCK_JOB_COMPLETE events regardless of whether
      the job was cancelled (kept the original disk) or completed (pivoted
      to the new disk), we have to track which of the two operations were
      used to end the job.  Furthermore, we'd like to avoid attempts to
      end a job where we are already waiting on an earlier request to qemu
      to end the job.  Likewise, if we miss the qemu event (perhaps because
      it arrived during a libvirtd restart), we still need enough state
      recorded to be able to determine how to modify the domain XML once
      we reconnect to qemu and manually learn whether the job still exists.
      
      Although this patch doesn't actually fix the problem, it is a
      preliminary step that makes it possible to track whether a job
      has already begun steps towards completion.
      
      * src/conf/domain_conf.h (virDomainDiskMirrorState): New enum.
      (_virDomainDiskDef): Convert bool mirroring to new enum.
      * src/conf/domain_conf.c (virDomainDiskDefParseXML)
      (virDomainDiskDefFormat): Handle new values.
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Adjust
      client.
      * src/qemu/qemu_driver.c (qemuDomainBlockPivot)
      (qemuDomainBlockJobImpl): Likewise.
      * docs/schemas/domaincommon.rng (diskMirror): Expose new values.
      * docs/formatdomain.html.in (elementsDisks): Document it.
      * tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      9a212d67
  9. 29 7月, 2014 1 次提交
    • M
      qemu: Utilize virFileFindHugeTLBFS · 725a211f
      Michal Privoznik 提交于
      Use better detection of hugetlbfs mount points. Yes, there can be
      multiple mount points each serving different huge page size.
      
      Since we already have ability to override the mount point in the
      qemu.conf file, this crazy backward compatibility code is brought in.
      Now we allow multiple mount points, so the "hugetlbfs_mount" option
      must take an list of strings (mount points). But previously, it was
      just a string, so we must accept both types now.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      725a211f
  10. 25 7月, 2014 2 次提交
    • P
      qemu: Fix starting of VMs with empty CDROM drives · efdb9117
      Peter Krempa 提交于
      Since 24e5cafb (thankfully unreleased)
      when a VM with an empty disk drive would be started the code would call
      stat() on NULL path as a check was missing from the callback rendering
      machines unstartable.
      
      Report success when the path is empty (denoting an empty drive).
      efdb9117
    • M
      qemuConnectGetDomainCapabilities: Report error on unknown arch · 3d968f40
      Michal Privoznik 提交于
      If user hasn't provided any @emulatorbin, the qemuCaps are
      searched by @arch provided (which in fact can be guessed from the
      host). However, there's no guarantee that the qemu binary for
      @arch will exist.  Therefore qemu capabilities may be nonexistent
      too. If that's the case, we should throw an error message prior
      jumping onto 'cleanup' label as the helper lookup function
      remains silent on no search result.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      3d968f40
  11. 24 7月, 2014 8 次提交
  12. 23 7月, 2014 2 次提交
  13. 22 7月, 2014 2 次提交
  14. 21 7月, 2014 2 次提交
  15. 18 7月, 2014 1 次提交
  16. 17 7月, 2014 3 次提交
  17. 16 7月, 2014 2 次提交
    • E
      blockjob: wait for pivot to complete · 97c59b9c
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1119173 documents that
      commit eaba79d2 was flawed in the implementation of the
      VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag when it comes to completing
      a blockcopy.  Basically, the qemu pivot action is async (the QMP
      command returns immediately, but the user must wait for the
      BLOCK_JOB_COMPLETE event to know that all I/O related to the job
      has finally been flushed), but the libvirt command was documented
      as synchronous by default.  As active block commit will also be
      using this code, it is worth fixing now.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Don't skip wait
      loop after pivot.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      97c59b9c
    • 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
  18. 15 7月, 2014 2 次提交
    • 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
  19. 09 7月, 2014 3 次提交
    • J
      qemu: fix domxml-to-native failing when spice_tls is not enabled · e871ab88
      Jincheng Miao 提交于
      The default graphics channel mode is 'any', so as to defaultMode attribute.
      If defaultMode and channel mode are all the default value 'any',
      qemuConnectDomainXMLToNative will set TLSPort.
      But in qemuBuildGraphicsSPICECommandLine, if spice_tls is not enabled, libvirtd
      will report an error to tell the user that spice TLS is disabled in qemu.conf.
      
      So qemuConnectDomainXMLToNative should check spice_tls is enabled,
      then decide to allocate an tlsPort number to this graphics.
      
      If user specified defaultMode is 'secure', qemuConnectDomainXMLToNative
      could allocate tlsPort, and then let qemuBuildGraphicsSPICECommandLine reports
      the spice_tls disabled error.
      
      The related bug is:
      https://bugzilla.redhat.com/show_bug.cgi?id=1113868Signed-off-by: NJincheng Miao <jmiao@redhat.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      e871ab88
    • P
      qemu: snapshot: Refactor image labelling of new snapshot files · 52c21204
      Peter Krempa 提交于
      Now that cgroups/security driver/locking driver support labelling of
      individual images and tolerate network storage we don't have to refrain
      from passing all image files to it. This allows removing the checking
      code as we already make sure that the snapshot function won't be called
      with unsupported options.
      52c21204
    • P
      qemu: Refactor qemuDomainPrepareDiskChainElement · 66df8bf4
      Peter Krempa 提交于
      Now that security, cgroup and locking APIs support working on individual
      images and we track the backing chain security info on a per-image basis
      we can finally kill swapping the disk source in virDomainDiskDef and use
      the virStorageSource directly.
      66df8bf4