1. 12 8月, 2014 5 次提交
    • M
      qemu_conf: Undefine the correct symbol · bf4cbe40
      Michal Privoznik 提交于
      At the beginning of the qemu config file parsing function there
      are 3 helper macros defined: GET_VALUE_BOOL, GET_VALUE_LONG and
      GET_VALUE_STR. Later, when they are no longer needed they are
      undefined in order to keep the namespace clean. However, the
      GET_VALUE_STRING is undefined instead of GET_VALUE_STR.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      bf4cbe40
    • R
      storage: ZFS support · 0257d06b
      Roman Bogorodskiy 提交于
      Implement ZFS storage backend driver. Currently supported
      only on FreeBSD because of ZFS limitations on Linux.
      
      Features supported:
      
       - pool-start, pool-stop
       - pool-info
       - vol-list
       - vol-create / vol-delete
      
      Pool definition looks like that:
      
       <pool type='zfs'>
        <name>myzfspool</name>
        <source>
          <name>actualpoolname</name>
        </source>
       </pool>
      
      The 'actualpoolname' value is a name of the pool on the system,
      such as shown by 'zpool list' command. Target makes no sense
      here because volumes path is always /dev/zvol/$poolname/$volname.
      
      User has to create a pool on his own, this driver doesn't
      support pool creation currently.
      
      A volume could be used with Qemu by adding an entry like this:
      
          <disk type='volume' device='disk'>
            <driver name='qemu' type='raw'/>
            <source pool='myzfspool' volume='vol5'/>
            <target dev='hdc' bus='ide'/>
          </disk>
      0257d06b
    • P
      qemu: migration: Check domain live state after exitting the monitor · 1b7c2c54
      Peter Krempa 提交于
      In qemuMigrationToFile we enter the monitor multiple times and don't
      check if the VM is still alive after returning form the monitor. Add the
      checks to skip pieces of code in case the VM crashes while saving it's
      state.
      1b7c2c54
    • P
      qemu: managedsave: Check that VM is alive after entering async job · 3fe9f61d
      Peter Krempa 提交于
      Saving a shutoff VM doesn't make sense and libvirtd crashes while
      attempting to do that. Check that the domain is alive after entering
      the save async job.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1129207
      3fe9f61d
    • P
      qemu: process: Fix header format of qemuProcessSetVcpuAffinities · e3f5af6a
      Peter Krempa 提交于
      Fix header alignment and remove the unused conn parameter.
      e3f5af6a
  2. 11 8月, 2014 2 次提交
    • T
      qemu: use guest-fsfreeze-freeze-list command if mountpoints to freeze specified · 09dbb478
      Tomoki Sekiyama 提交于
      A command to freeze a part of mounted file systems is implemented in
      upstream QEMU-guest-agent with a name of 'guest-fsfreeze-freeze-list'.
      This fixes the name of the command used to partial fsfreeze in qemu driver
      when 'mountpoints' option is specified to virDomainFSFreeze API.
      Signed-off-by: NTomoki Sekiyama <tomoki.sekiyama@hds.com>
      09dbb478
    • 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
  3. 08 8月, 2014 3 次提交
    • P
      e260a0e6
    • J
      qemu: Remove extraneous space in function prototypes · 2e194e5b
      John Ferlan 提交于
      During review of the iSCSI hostdev series, eblake noted that the
      prototypes shouldn't have the extranenous space between the "*" and
      the function name:
      
      http://www.redhat.com/archives/libvir-list/2014-July/msg01227.html
      
      Since it was more invasive than 1 or 2 lines - I said I'd send a
      patch covering this once committed.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      2e194e5b
    • 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
  4. 07 8月, 2014 1 次提交
  5. 06 8月, 2014 2 次提交
  6. 04 8月, 2014 2 次提交
    • 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
    • M
      qemu: fix comment in qemu.conf · b2574b47
      Martin Kletzander 提交于
      There are multiple mount points after commit 725a211f, but one comment
      wasn't changed to use plurals.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      b2574b47
  7. 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
  8. 29 7月, 2014 4 次提交
    • H
      qemu: error out if PCI passthrough type is not supported · c5b02b67
      Hu Tao 提交于
      If PCI passthrough type is not supported, we should error out rather than
      continue building the command line.
      
      When starting a domain, the type has been already checked by
      qemuPrepareHostdevPCICheckSupport() before building qemu command line,
      so the problem doesn't emerge.
      
      But when coverting a domain xml without specifying passthrough type explictly
      to qemu arg, we will get a malformed command line.
      
      the xml:
      
          <hostdev mode='subsystem' type='pci' managed='yes'>
            <source>
              <address domain='0x0001' bus='0x03' slot='0x00' function='0x0'/>
            </source>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
          </hostdev>
      
      the converted command line:
      
        -device ,host=0001:03:00.0,id=hostdev0,bus=pci.0,addr=0x5
      
      After this patch, virsh gives an error message:
      
        virsh domxml-to-native qemu-argv /tmp/tmp.xml
        error: internal error: invalid PCI passthrough type 'default'
      Signed-off-by: NHu Tao <hutao@cn.fujitsu.com>
      c5b02b67
    • M
    • M
      domain: Introduce ./hugepages/page/[@size, @unit, @nodeset] · 136ad497
      Michal Privoznik 提交于
        <memoryBacking>
          <hugepages>
            <page size="1" unit="G" nodeset="0-3,5"/>
            <page size="2" unit="M" nodeset="4"/>
          </hugepages>
        </memoryBacking>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      136ad497
    • 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
  9. 28 7月, 2014 3 次提交
  10. 25 7月, 2014 4 次提交
    • 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
    • P
      virtio-rng: allow multiple RNG devices · bbddbefa
      Peter Krempa 提交于
      qemu supports adding multiple RNG devices. This patch allows libvirt to
      support this.
      bbddbefa
    • P
      qemu: cgroup: Don't use NULL path on default backed RNGs · 99ff49ee
      Peter Krempa 提交于
      The "random" backend for virtio-rng can be started with no path
      specified which equals to /dev/random. The cgroup code didn't consider
      this and called few of the functions with NULL resulting into:
      
       $ virsh start rng-vm
       error: Failed to start domain rng-vm
       error: Path '(null)' is not accessible: Bad address
      
      Problem introduced by commit c6320d34
      99ff49ee
    • 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 10 次提交