1. 16 11月, 2014 22 次提交
    • W
      qemu: stop NBD server after successful migration · dbc11c4f
      Weiwei Li 提交于
      In qemuMigrationFinish mig->nbd can not be initialized by
      qemuMigrationEatCookie without the QEMU_MIGRATION_COOKIE_NBD flag.
      That causes qemuMigrationStopNBDServer to return early without
      stopping the NBD server properly.
      Signed-off-by: NWeiwei Li <nuonuoli@tencent.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      (cherry picked from commit c3012a02)
      dbc11c4f
    • M
      qemu: make sure capability probing process can start · 963d0bb5
      Martin Kletzander 提交于
      When daemon is killed right in the middle of probing a qemu binary for
      its capabilities, the qemu process is left running.  Next time the
      daemon is starting, it cannot start the probing qemu process because the
      one that's already running does have the pidfile flock()'d.
      Reported-by: NWang Yufei <james.wangyufei@huawei.com>
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit 0ed1b55b)
      963d0bb5
    • M
      util: Introduce virPidFileForceCleanupPath · 595a1c88
      Martin Kletzander 提交于
      This function is used to cleanup a pidfile doing whatever it takes, even
      killing the owning process.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit d1fd086e)
      595a1c88
    • M
      qemu: make advice from numad available when building commandline · 08182c7f
      Martin Kletzander 提交于
      Particularly in qemuBuildNumaArgStr(), there was a need for the advice
      due to memory backing, which needs to know the nodeset it will be pinned
      to.  With newer qemu this caused the following error when starting
      domain:
      
        error: internal error: Advice from numad is needed in case of
        automatic numa placement
      
      even when starting perfectly valid domain, e.g.:
      
        ...
        <vcpu placement='auto'>4</vcpu>
        <numatune>
          <memory mode='strict' placement='auto'/>
        </numatune>
        <cpu>
          <numa>
            <cell id='0' cpus='0' memory='524288'/>
            <cell id='1' cpus='1' memory='524288'/>
          </numa>
        </cpu>
        ...
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1138545Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit 11a48758)
      08182c7f
    • W
      qemu: Release nbd port from migrationPorts instead of remotePorts · 65599f27
      weiwei li 提交于
      commit 3e1e16aa (Use a port from the
      migration range for NBD as well) changed ndb port allocation from
      remotePorts to migrationPorts, but did not change the port releasing
      process, which makes an error when migrating several times (above 64):
      error: internal error: Unable to find an unused port in range
      'migration' (49152-49215)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1159245Signed-off-by: NWeiwei Li <nuonuoli@tencent.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      (cherry picked from commit be598c5f)
      65599f27
    • E
      qemu: better error message when block job can't succeed · ecfdfb15
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
      the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
      block jobs by removing the 'block-stream' QMP command, while still
      leaving 'block-job-cancel' as an unusable no-op.  Meanwhile, we
      already had existing code that checked whether block jobs were
      completely missing (such as qemu 0.15), old style (cancel is
      synchronous, and all commands spelled with '_'), or new style
      (cancel is asynchronous, and all commands spelled with '-'), and
      used that three-way probe to give decent error messages.  At the
      time that code was added, all existing qemu versions fell in one
      of three buckets, and the code was using the presence of
      'block-job-cancel' as the witness of which of the three buckets.
      But now that RHEL qemu has shipped with intentionally crippled
      'block-stream', we have a fourth bucket, which results in ugly
      error messages when trying 'virsh blockpull':
      
       error: Requested operation is not valid: Command 'block-stream' is not found
      
      In reality, the fourth bucket should be treated the same as the
      first bucket (no block job support); we can do that by realizing
      that no existing build of qemu has working block-stream while
      lacking block-job-cancel, so it is easiest to change our witness
      to the command that starts a job rather than ends one.  We still
      act correctly regarding command spelling and whether cancel is
      asynchronous.  And on crippled RHEL builds, we now get the desired:
      
       error: unsupported configuration: block jobs not supported with this qemu binary
      
      [1] The intentional cripple is limited to qemu-kvm of RHEL; when using
      qemu-kvm-rhev of RHEV, block job functionality is supported.  Don't ask
      me to explain the "why" behind it all - I'm just dealing with fallout
      from someone else's decision.
      
      * src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
      * src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
      rather than cancel when determining the flavor of block jobs supported.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 00331bfb)
      ecfdfb15
    • P
      test: Add test to verify helpers used for backing file name parsing · 28a3732d
      Peter Krempa 提交于
      Add two test cases to verify that the helpers split and parse the
      backing store components properly.
      
      (cherry picked from commit 95a56835)
      28a3732d
    • P
      storage: Fix crash when parsing backing store URI with schema · b8bf1188
      Peter Krempa 提交于
      The code that parses the schema from the URI touches the "hosts[0]"
      member of the storage file source structure in case the URI contains a
      schema. The hosts array was not yet allocated at the point in the code
      where the transport protocol was parsed and set. This lead to a crash of
      libvirtd.
      
      Fix the code by allocating the "hosts" array upfront and add a test case
      to verify this scenario. (Unfortunately this requires shuffling the test
      case numbers too).
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288
      (cherry picked from commit 98784369)
      b8bf1188
    • J
      remote: fix jump depends on uninitialised value · 05243276
      Jincheng Miao 提交于
      Currently remote driver only initializes partial fields of
      remote_connect_get_all_domain_stats_args. But xdr_array()
      will check the uninitialised field 'doms_val'.
      For safty reason, memset all fields of args is better.
      
      Fix the following error from valgrind, like:
      ==30515== 1 errors in context 1 of 3:
      ==30515== Conditional jump or move depends on uninitialised value(s)
      ==30515==    at 0x85E9402: xdr_array (xdr_array.c:88)
      ==30515==    by 0x4FD8FC9: xdr_remote_connect_get_all_domain_stats_args (remote_protocol.c:6473)
      ==30515==    by 0x4FE72F2: virNetMessageEncodePayload (virnetmessage.c:350)
      ==30515==    by 0x4FDD21C: virNetClientProgramCall (virnetclientprogram.c:326)
      ==30515==    by 0x4FB4D01: callFull.isra.2 (remote_driver.c:6667)
      ==30515==    by 0x4FCBD45: call (remote_driver.c:6689)
      ==30515==    by 0x4FCBD45: remoteConnectGetAllDomainStats (remote_driver.c:7793)
      ==30515==    by 0x4FA0E75: virConnectGetAllDomainStats (libvirt.c:21678)
      ==30515==    by 0x147FD1: cmdDomstats (virsh-domain-monitor.c:2148)
      ==30515==    by 0x13006B: vshCommandRun (virsh.c:1915)
      ==30515==    by 0x12A9E1: main (virsh.c:3699)
      Signed-off-by: NJincheng Miao <jmiao@redhat.com>
      (cherry picked from commit 28b7601d)
      05243276
    • M
      qemu_agent: Produce more readable error messages · b6366531
      Michal Privoznik 提交于
      Not every error message from qemu-ga has to have the 'class' field
      filled out. For instance, I've seen this error message lately:
      
        qemuAgentCheckError:1047 : unable to execute QEMU agent command \
        {"execute":"guest-set-time"}: \
        {"error":{"desc":"Invalid parameter type, expected: integer"}}
      
      However, this got translated into rather generic error message:
      
        internal error: unable to execute QEMU agent command
        'guest-set-time': unknown QEMU command error
      
      So we've dropped better error message in favor of a generic one.
      This is due to our code which expects 'class' which is not
      present here.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit b7fe5a65)
      b6366531
    • E
      qemu: forbid snapshot-delete --children-only on external snapshot · 3b4b9aee
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
      given a domain where an internal snapshot parent has an external
      snapshot child, we lacked a safety check when trying to use the
      --children-only option to snapshot-delete:
      
      $ virsh start dom
      $ virsh snapshot-create-as dom internal
      $ virsh snapshot-create-as dom external --disk-only
      $ virsh snapshot-delete dom external
      error: Failed to delete snapshot external
      error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
      $ virsh snapshot-delete dom internal --children
      error: Failed to delete snapshot internal
      error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
      $ virsh snapshot-delete dom internal --children-only
      Domain snapshot internal children deleted
      
      While I'd still like to see patches that actually do proper external
      snapshot deletion, we should at least fix the inconsistency in the
      meantime.  With this patch:
      
      $ virsh snapshot-delete dom internal --children-only
      error: Failed to delete snapshot internal
      error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 2086a990)
      3b4b9aee
    • J
      tests: Add SELINUX_LIBS to fix viridentitytest linker bug · 0940208b
      Julio Faracco 提交于
      In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile.
      Even if all the SELINUX libraries and depedencies are installed. See the error
      message below:
      
      [...]
        CC       viridentitytest.o
        CCLD     viridentitytest
      /usr/bin/ld: viridentitytest.o: undefined reference to symbol
                                                             'security_disable'
      //lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing
                                                                 from command line
      collect2: error: ld returned 1 exit status
      make: *** [viridentitytest] Error 1
      
      Simply adding the variable SELINUX_LIBS in viridentitytest rules of
      Makefile.am to include SELINUX libraries into viridentitytest solved that
      compilation issue.
      Signed-off-by: NJulio Faracco <jcfaracco@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit f2a2d0e9)
      0940208b
    • P
      qemu: migration: Make check for empty hook XML robust · a70d93e2
      Peter Krempa 提交于
      Also consider whitespace only strings returned from the hook as empty
      result.
      
      (cherry picked from commit 19b1ee42)
      a70d93e2
    • P
      qemu: restore: Fix restoring of VM when the restore hook returns empty XML · 3d52d5e6
      Peter Krempa 提交于
      The documentation for the restore hook states that returning an empty
      XML is equivalent with copying the input. There was a bug in the code
      checking the returned string by checking the string instead of the
      contents. Use the new helper to check if the string is empty.
      
      (cherry picked from commit e3867799)
      3d52d5e6
    • P
      util: string: Add helper to check whether string is empty · 1bcf7e10
      Peter Krempa 提交于
      The helper checks whether a string contains only whitespace or is NULL.
      This will be helpful to skip cases where a user string is optional, but
      may be provided empty with the same meaning.
      
      (cherry picked from commit 0eeafeed)
      1bcf7e10
    • P
      virsh: domain: Use global constant for XML file size limit · 5d02a123
      Peter Krempa 提交于
      Few places still used hardcoded limit for maximum XML size for commands
      that accept XML files. The hardcoded limits ranged from 8k to 1M. Use
      VSH_MAX_XML_FILE to express this limit in a unified way. This will bump
      the limit for the commands that used hardcoded string lengths to 10M.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1152427
      (cherry picked from commit 4d1852c4)
      5d02a123
    • J
      qemu: Fix hot unplug of SCSI_HOST device · e1a3efda
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1141732
      
      Introduced by commit id '8f76ad99' the logic to detach a scsi_host
      device (SCSI or iSCSI) fails when attempting to remove the 'drive'
      because as I found in my investigation - the DelDevice takes care of
      that for us.
      
      The investigation turned up commits to adjust the logic for the
      qemuMonitorDelDevice and qemuMonitorDriveDel processing for interfaces
      (commit id '81f76598'), disk bus=VIRTIO,SCSI,USB (commit id '0635785b'),
      and chr devices (commit id '55b21f9b'), but nothing with the host devices.
      
      This commit uses the model for the previous set of changes and applies
      it to the hostdev path. The call to qemuDomainDetachHostSCSIDevice will
      return to qemuDomainDetachThisHostDevice handling either the audit of
      the failure or the wait for the removal and then call into
      qemuDomainRemoveHostDevice for the event, removal from the domain hostdev
      list, and audit of the removal similar to other paths.
      
      NOTE: For now the 'conn' param to +qemuDomainDetachHostSCSIDevice is left
      as ATTRIBUTE_UNUSED.  Removing requires a cascade of other changes to be
      left for a future patch.
      
      (cherry picked from commit d2774e54)
      e1a3efda
    • M
      qemu: unref cfg after TerminateMachine has been called · 86d26c42
      Martin Kletzander 提交于
      Commit 4882618e added the code that
      requests driver cfg, but forgot to unref it.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit 9661ac2f)
      86d26c42
    • J
      Add virCgroupTerminateMachine stub · a91a960f
      Ján Tomko 提交于
      Fix the build on FreeBSD, broken by commit 4882618e.
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      (cherry picked from commit 99b2b457)
      a91a960f
    • G
      qemu: use systemd's TerminateMachine to kill all processes · 870ea74e
      Guido Günther 提交于
      If we don't properly clean up all processes in the
      machine-<vmname>.scope systemd won't remove the cgroup and subsequent vm
      starts fail with
      
        'CreateMachine: File exists'
      
      Additional processes can e.g. be added via
      
        echo $PID > /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks
      
      but there are other cases like
      
        http://bugs.debian.org/761521
      
      Invoke TerminateMachine to be on the safe side since systemd tracks the
      cgroup anyway. This is a noop if all processes have terminated already.
      
      (cherry picked from commit 4882618e)
      870ea74e
    • M
      util: Prepare URI formatting for libxml2 >= 2.9.2 · 3d021408
      Martin Kletzander 提交于
      Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5 libxml2 removes
      two slashes from the URI when there is no server part.  This is fixed
      with beb7281055dbf0ed4d041022a67c6c5cfd126f25, but only if the calling
      application calls xmlSaveUri() on URI that xmlURIParse() parsed.  And
      that is not the case in virURIFormat().  virURIFormat() accepts
      virURIPtr that can be created without parsing it and we do that when we
      format network storage paths for gluster for example.  Even though
      virStorageSourceParseBackingURI() uses virURIParse(), it throws that data
      structure right away.
      
      Since we want to format URIs as URIs and not absolute URIs or opaque
      URIs (see RFC 3986), we can specify that with a special hack thanks to
      commit beb7281055dbf0ed4d041022a67c6c5cfd126f25, by setting port to -1.
      
      This fixes qemuxml2argvtest test where the disk-drive-network-gluster
      case was failing.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit 8f17d0ea)
      3d021408
    • M
      security_selinux: Don't relabel /dev/net/tun · d72e79ed
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1147057
      
      The code for relabelling the TAP FD is there due to a race. When
      libvirt creates a /dev/tapN device it's labeled as
      'system_u:object_r:device_t:s0' by default. Later, when
      udev/systemd reacts to this device, it's relabelled to the
      expected label 'system_u:object_r:tun_tap_device_t:s0'. Hence, we
      have a code that relabels the device, to cut the race down. For
      more info see ae368ebf.
      
      But the problem is, the relabel function is called on all TUN/TAP
      devices. Yes, on /dev/net/tun too. This is however a special kind
      of device - other processes uses it too. We shouldn't touch it's
      label then.
      
      Ideally, there would an API in SELinux that would label just the
      passed FD and not the underlying path. That way, we wouldn't need
      to care as we would be not labeling /dev/net/tun but the FD
      passed to the domain. Unfortunately, there's no such API so we
      have to workaround until then.
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit ebc05263)
      d72e79ed
  2. 13 11月, 2014 1 次提交
    • L
      util: eliminate "use after free" in callers of virNetDevLinkDump · 7caed3d4
      Laine Stump 提交于
      virNetDevLinkDump() gets a message from netlink into "resp", then
      calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
      then returns tb to its caller, but not before freeing the buffer at
      resp. That means that all the callers of virNetDevLinkDump() are
      examining memory that has already been freed. This can be verified by
      filling the buffer at resp with garbage prior to freeing it (or, I
      suppose, just running libvirtd under valgrind) then performing some
      operation that calls virNetDevLinkDump().
      
      The upstream commit log incorrectly states that the code has been like
      this ever since virNetDevLinkDump() was written. In reality, the
      problem was introduced with commit e95de74d, first in libvirt-1.0.5,
      which was attempting to eliminate a typecast that caused compiler
      warnings. It has only been pure luck (or maybe a lack of heavy load,
      and/or maybe an allocation algorithm in malloc() that delays re-use of
      just-freed memory) that has kept this from causing errors, for example
      when configuring a PCI passthrough or macvtap passthrough network
      interface.
      
      The solution taken in this patch is the simplest - just return resp to
      the caller along with tb, then have the caller free it after they are
      finished using the data (pointers) in tb. I alternately could have
      made a cleaner interface by creating a new struct that put tb and resp
      together along with a vir*Free() function for it, but this function is
      only used in a couple places, and I'm not sure there will be
      additional new uses of virNetDevLinkDump(), so the value of adding a
      new type, extra APIs, etc. is dubious.
      
      (cherry picked from commit f9f9699f)
      7caed3d4
  3. 07 11月, 2014 1 次提交
    • E
      CVE-2014-7823: dumpxml: security hole with migratable flag · 744ddb15
      Eric Blake 提交于
      Commit 28f8dfdc (v1.0.0) introduced a security hole: in at least
      the qemu implementation of virDomainGetXMLDesc, the use of the
      flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
      connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
      prior to calling qemuDomainFormatXML.  However, the use of
      VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
      clients only.  This patch treats the migratable flag as requiring
      the same permissions, rather than analyzing what might break if
      migratable xml no longer includes secret information.
      
      Fortunately, the information leak is low-risk: all that is gated
      by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
      but VNC passwords are already weak (FIPS forbids their use, and
      on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
      password sent in plaintext over the network deserves what they
      get).  SPICE offers better security than VNC, and all other
      secrets are properly protected by use of virSecret associations
      rather than direct output in domain XML.
      
      * src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
      Tighten rules on use of migratable flag.
      * src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit b1674ad5)
      
      Conflicts:
      	src/libvirt-domain.c - file split from older src/libvirt.c
      Signed-off-by: NEric Blake <eblake@redhat.com>
      744ddb15
  4. 30 10月, 2014 3 次提交
    • L
      qemu: x86_64 is good enough for i686 · cd1b72fd
      Lubomir Rintel 提交于
      virt-manager on Fedora sets up i686 hosts with "/usr/bin/qemu-kvm" emulator,
      which in turn unconditionally execs qemu-system-x86_64 querying capabilities
      then fails:
      
      Error launching details: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'
      
      Traceback (most recent call last):
        File "/usr/share/virt-manager/virtManager/engine.py", line 748, in _show_vm_helper
          details = self._get_details_dialog(uri, vm.get_connkey())
        File "/usr/share/virt-manager/virtManager/engine.py", line 726, in _get_details_dialog
          obj = vmmDetails(conn.get_vm(connkey))
        File "/usr/share/virt-manager/virtManager/details.py", line 399, in __init__
          self.init_details()
        File "/usr/share/virt-manager/virtManager/details.py", line 784, in init_details
          domcaps = self.vm.get_domain_capabilities()
        File "/usr/share/virt-manager/virtManager/domain.py", line 518, in get_domain_capabilities
          self.get_xmlobj().os.machine, self.get_xmlobj().type)
        File "/usr/lib/python2.7/site-packages/libvirt.py", line 3492, in getDomainCapabilities
          if ret is None: raise libvirtError ('virConnectGetDomainCapabilities() failed', conn=self)
      libvirtError: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'
      
      Journal:
      
      Oct 16 21:08:26 goatlord.localdomain libvirtd[1530]: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'
      
      (cherry picked from commit afe8f420)
      cd1b72fd
    • C
      qemu: Don't compare CPU against host for TCG · e9bf19a4
      Cole Robinson 提交于
      Right now when building the qemu command line, we try to do various
      unconditional validations of the guest CPU against the host CPU. However
      this checks are overly applied. The only time we should use the checks
      are:
      
      - The user requests host-model/host-passthrough, or
      
      - When KVM is requsted. CPU features requested in TCG mode are always
        emulated by qemu and are independent of the host CPU, so no host CPU
        checks should be performed.
      
      Right now if trying to specify a CPU for arm on an x86 host, it attempts
      to do non-sensical validation and falls over.
      
      Switch all the test cases that were intending to test CPU validation to
      use KVM, so they continue to test the intended code.
      
      Amend some aarch64 XML tests with a CPU model, to ensure things work
      correctly.
      
      (cherry picked from commit cf7fce8f2fd1c930f357fd4ff93ac35f38eb30c6)
      e9bf19a4
    • C
      qemu_command: Split qemuBuildCpuArgStr · 74e27d1c
      Cole Robinson 提交于
      Move the CPU mode/model handling to its own function. This is just
      code movement and re-indentation.
      
      (cherry picked from commit e1d872dc77c80d43036f928f83f560f2e9286148)
      74e27d1c
  5. 01 10月, 2014 2 次提交
  6. 30 9月, 2014 5 次提交
  7. 29 9月, 2014 3 次提交
  8. 27 9月, 2014 1 次提交
  9. 26 9月, 2014 2 次提交