1. 27 8月, 2014 2 次提交
    • E
      API: Tweak virDomainOpenGraphics to return fd directly · b259e459
      Eric Blake 提交于
      Let's fix this before we bake in a painful API.  Since we know
      that we have exactly one non-negative fd on success, we might
      as well return the fd directly instead of forcing the user to
      pass in a pointer.  Furthermore, I found some memory and fd
      leaks while reviewing the code - the idea is that on success,
      libvirtd will have handed two fds in two different directions:
      one to qemu, and one to the RPC client.
      
      * include/libvirt/libvirt.h.in (virDomainOpenGraphicsFD): Drop
      unneeded parameter.
      * src/driver.h (virDrvDomainOpenGraphicsFD): Likewise.
      * src/libvirt.c (virDomainOpenGraphicsFD): Adjust interface to
      return fd directly.
      * daemon/remote.c (remoteDispatchDomainOpenGraphicsFd): Adjust
      semantics.
      * src/qemu/qemu_driver.c (qemuDomainOpenGraphicsFD): Likewise,
      and plug fd leak.
      * src/remote/remote_driver.c (remoteDomainOpenGraphicsFD):
      Likewise, and plug memory and fd leak.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b259e459
    • J
  2. 23 8月, 2014 1 次提交
    • E
      qemu: check for active domain after agent interaction · 2c551d34
      Eric Blake 提交于
      Commit b606bbb4 reminded me that any time we drop locks to run
      back-to-back guest interaction commands, we have to check that
      the guest didn't disappear in between the two commands.  A quick
      audit found a couple of spots that were missing this check.
      
      * src/qemu/qemu_driver.c (qemuDomainShutdownFlags)
      (qemuDomainSetVcpusFlags): Check that domain is still up.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2c551d34
  3. 21 8月, 2014 1 次提交
    • J
      Perform disk config validity checking for attach-device config · 33188c9f
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1078126
      
      Using 'virsh attach-device --config' (or --persistent) to attach a
      file backed lun device will succeed; however, subsequent domain restarts
      will result in failure because the configuration of a file backed lun
      is not supported.
      
      Although allowing 'illegal configurations' is something that can be
      allowed, it may not be practical in this case. Generally, when attaching
      a device to a domain means the domain must be running. A way around
      this is using the --config (or --persistent) option. When an attach
      is done to a running domain, a temporary configuration is modified
      first followed by the live update. The live update will make a number
      of disk validity checks when building the qemu command to attach the
      disk. If any fail, then change is rejected.
      
      Rather than allow a potentially illegal combination, adjust the code
      in the configuration path to make the same checks as the running path
      will make with respect to disk validity checks. This way we avoid
      having the potential for some subsequent start/reboot to fail because
      an illegal combination was allowed.
      
      NB: The live path still checks the configuration since it is possible
      to just do --live guest modification...
      33188c9f
  4. 20 8月, 2014 10 次提交
  5. 19 8月, 2014 1 次提交
  6. 18 8月, 2014 1 次提交
  7. 14 8月, 2014 1 次提交
  8. 12 8月, 2014 1 次提交
  9. 11 8月, 2014 1 次提交
    • J
      qemu: Actually clear bandwidth settings · 337c6eec
      Jianwei Hu 提交于
      The virDomainSetInterfaceParameters implementation in qemu over
      VIR_DOMAIN_AFFECT_CONFIG doesn't work as expected. When trying to
      clear out the bandwidth settings for an interface, it has no
      actual effect:
      
          virsh # domiftune --config $domain $interface
          inbound.average: 100
          inbound.peak   : 0
          inbound.burst  : 0
          outbound.average: 10
          outbound.peak  : 0
          outbound.burst : 0
      
          virsh domiftune --config $domain $interface 0 0
      
          virsh # domiftune --config $domain $interface
          inbound.average: 100
          inbound.peak   : 0
          inbound.burst  : 0
          outbound.average: 10
          outbound.peak  : 0
          outbound.burst : 0
      
      But according to virsh man page:
      
          To clear inbound or outbound settings, use --inbound or
          --outbound respectfully with average value of zero.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      337c6eec
  10. 08 8月, 2014 1 次提交
    • E
      blockjob: fix use-after-free in blockcopy · 265680c5
      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>
      265680c5
  11. 06 8月, 2014 2 次提交
  12. 04 8月, 2014 1 次提交
    • J
      Don't overwrite errors from virNetDevBandwidthSet · 6dac5d06
      Ján Tomko 提交于
      Otherwise this beautiful error would be overwritten when
      the function is called with a really high rate number:
      
      2014-07-28 12:51:47.920+0000: 2304: error : virCommandWait:2399 :
      internal error: Child process (/sbin/tc class add dev vnet0 parent 1:
      classid 1:1 htb rate 4294968kbps) unexpected exit status 1: Illegal "rate"
      Usage: ... qdisc add ... htb [default N] [r2q N]
       default  minor id of class to which unclassified packets are sent {0}
       r2q      DRR quantums are computed as rate in Bps/r2q {10}
       debug    string of 16 numbers each 0-3 {0}
      
      ... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                            [prio P] [slot S] [pslot PS]
                            [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
       rate     rate allocated to this class (class can still borrow)
       burst    max bytes burst which can be accumulated during idle period {computed}
       mpu      minimum packet size used in rate computations
       overhead per-packet size overhead used in rate computations
       linklay  adapting to a linklayer e.g. atm
       ceil     definite upper class rate (no borrows) {rate}
       cburst   burst but for ceil {computed}
       mtu      max packet size we create rate map for {1600}
       prio     priority of leaf; lowe
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1043735
      6dac5d06
  13. 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
  14. 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
  15. 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
  16. 24 7月, 2014 8 次提交
  17. 23 7月, 2014 2 次提交