1. 17 12月, 2014 4 次提交
    • E
      qemu: let blockinfo reuse virStorageSource · 89646e69
      Eric Blake 提交于
      Right now, grabbing blockinfo always calls stat on the disk, then
      opens the image to determine the capacity, using a throw-away
      virStorageSourcePtr.  This has a couple of drawbacks:
      
      1. We are calling stat and opening a file on every invocation of
      the API.  However, there are cases where the stats should NOT be
      changing between successive calls (if a domain is running, no
      one should be changing the physical size of a block device or raw
      image behind our backs; capacity of read-only files should not
      be changing; and we are the gateway to the block-resize command
      to know when the capacity of read-write files should be changing).
      True, we still have to use stat in some cases (a sparse raw file
      changes allocation if it is read-write and the amount of holes is
      changing, and a read-write qcow2 image stored in a file changes
      physical size if it was not fully pre-allocated).  But for
      read-only images, even this should be something we can remember
      from the previous time, rather than repeating every call.
      
      2. We want to enhance the power of virDomainListGetStats, by
      sharing code.  But we already have a virStorageSourcePtr for
      each disk, and it would be easier to reuse the common structure
      than to have to worry about the one-off virDomainBlockInfoPtr.
      
      While this patch does not optimize reuse of information in point
      1, it does get us closer to being able to do so; by updating a
      structure that survives between consecutive calls.
      
      * src/util/virstoragefile.h (_virStorageSource): Add physical, to
      mirror virDomainBlockInfo; rearrange fields to match public struct.
      (virStorageSourceCopy): Copy the new field.
      * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Store into
      storage source, then copy to block info.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      89646e69
    • E
      qemu: refactor blockinfo job handling · a20c3aaf
      Eric Blake 提交于
      In order for a future patch to virDomainListGetStats to reuse
      some code for determining disk usage of offline domains, we
      need to make it easier to pull out part of the guts of grabbing
      blockinfo.  The current implementation grabs a job fairly late
      in the game, while getstats will already own a job; reordering
      things so that the job is always grabbed up front in both
      functions will make it easier to pull out the common code.
      This patch results in grabbing a job in cases where one was not
      previously needed, but as it is a query job, it should not be
      noticeably slower.
      
      This patch touches the same code as the fix for CVE-2014-6458
      (commit b7992595); in that patch, we avoided hotplug changing
      a disk reference during the time of obtaining a monitor lock
      by copying all data we needed and no longer referencing disk;
      this patch goes the other way and ensures that by holding the
      job, the disk cannot be changed so we no longer need to worry
      about the disk being invalidated across the monitor lock.
      
      * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Rearrange job
      control to be outside of disk information.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a20c3aaf
    • M
      qemu: Free saved error in qemuDomainSetVcpusFlags · 4d1e3943
      Martin Kletzander 提交于
      Commit e3435caf added cleanup code to qemuDomainSetVcpusFlags() that was
      not supposed to reset the error.  Usual procedure was done, saving the
      error to temporary variable, but it was never free'd, but rather leaked.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      4d1e3943
    • M
      qemu: Add missing goto error in qemuRestoreCgroupState · 86759ec6
      Martin Kletzander 提交于
      Commit af2a1f05 tried clearly separating each condition in
      qemuRestoreCgroupState() for the sake of readability, however somehow
      one condition body was missing.  That means that the body of the next
      condition got executed only if both of there were true, which is
      impossible, thus resulting in a dead code and a logic error.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      86759ec6
  2. 16 12月, 2014 4 次提交
  3. 15 12月, 2014 7 次提交
  4. 14 12月, 2014 2 次提交
    • L
      qemu: add a qemuInterfaceStopDevices(), called when guest CPUs stop · c5a54917
      Laine Stump 提交于
      We now have a qemuInterfaceStartDevices() which does the final
      activation needed for the host-side tap/macvtap devices that are used
      for qemu network connections. It will soon make sense to have the
      converse qemuInterfaceStopDevices() which will undo whatever was done
      during qemuInterfaceStartDevices().
      
      A function to "stop" a single device has also been added, and is
      called from the appropriate place in qemuDomainDetachNetDevice(),
      although this is currently unnecessary - the device is going to
      immediately be deleted anyway, so any extra "deactivation" will be for
      naught. The call is included for completeness, though, in anticipation
      that in the future there may be some required action that *isn't*
      nullified by deleting the device.
      
      This patch is a part of a more complete fix for:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1081461
      c5a54917
    • L
      qemu: always call qemuInterfaceStartDevices() when starting CPUs · 879c13d6
      Laine Stump 提交于
      The patch that added qemuInterfaceStartDevices() (upstream commit
      82977058) had an extra conditional to
      prevent calling it if the reason for starting the CPUs was
      VIR_DOMAIN_RUNNING_UNPAUSED or VIR_DOMAIN_RUNNING_SAVE_CANCELED.  This
      was put in by the author as the result of a reviewer asking if it was
      necessary to ifup the interfaces in *all* occasions (because these
      were the two cases where the CPU would have already been started (and
      stopped) once, so the interface would already be ifup'ed).
      
      It turns out that, as long as there is no corresponding
      qemuInterfaceStopDevices() to ifdown the interfaces anytime the CPUs
      are stopped, neglecting to ifup when reason is RUNNING_UNPAUSED or
      RUNNING_SAVE_CANCELED doesn't cause any problems (because it just
      happens that the interface will have already been ifup'ed by a prior
      call when the CPU was previously started for some other reason).
      
      However, it also doesn't *help*, and there will soon be a
      qemuInterfaceStopDevices() function which *will* ifdown these
      interfaces when the guest CPUs are stopped, and once that is done, the
      interfaces will be left down in some cases when they should be up (for
      example, if a domain is paused and then unpaused).
      
      So, this patch is removing the condition in favor of always calling
      qemuInterfaeStartDevices() when the guest CPUs are started.
      
      This patch (and the aforementioned patch) resolve:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1081461
      879c13d6
  5. 11 12月, 2014 2 次提交
  6. 10 12月, 2014 2 次提交
  7. 09 12月, 2014 6 次提交
    • P
      qemu: migration: Unlock vm on failed ACL check in protocol v2 APIs · 2bdcd29c
      Peter Krempa 提交于
      Avoid leaving the domain locked on a failed ACL check in
      qemuDomainMigratePerform() and qemuDomainMigrateFinish2().
      
      Introduced in commit abf75aea (Add ACL checks into the QEMU driver).
      2bdcd29c
    • L
      qemu: always use virDomainNetGetActualBridgeName to get interface's bridge · 4aae2ed6
      Laine Stump 提交于
      qemuNetworkIfaceConnect() used to have a special case for
      actualType='network' (a network with forward mode of route, nat, or
      isolated) to call the libvirt public API to retrieve the bridge being
      used by a network. That is no longer necessary - since all network
      types that use a bridge and tap device now get the bridge name stored
      in the ActualNetDef, we can just always use
      virDomainNetGetActualBridgeName() instead.
      
      (an audit of the two callers to qemuNetworkIfaceConnect() confirms
      that it is never called for any other type of network, so the dead
      code in the else statement (logging an internal error if it is called
      for any other type of network) is eliminated in the process.)
      4aae2ed6
    • L
      qemu: setup tap devices for macTableManager='libvirt' · 7cb822c2
      Laine Stump 提交于
      When libvirt is managing the MAC table of a Linux host bridge, it must
      turn off learning and unicast_flood for each tap device attached to
      that bridge, then add a Forwarding Database (fdb) entry for the tap
      device using the MAC address from the domain interface config.
      
      Once we have disabled learning and flooding, any packet that has a
      destination MAC address not present in the fdb will be dropped by the
      bridge. This, along with the opportunistic disabling of promiscuous
      mode[*], can result in enhanced network performance. and a potential
      slight security improvement.
      
      [*] If there is only one device on the bridge with learning/unicast_flood
      enabled, then that device will automatically have promiscuous mode
      disabled. If there are *no* devices with learning/unicast_flood
      enabled (e.g. for a libvirt "route", "nat", or isolated network that
      has no physical device attached), then all non-tap devices will have
      promiscuous mode disabled (tap devices always have promiscuous mode
      enabled, which may be a bug in the kernel, but in practice has 0
      effect).
      
      None of this has any effect for kernels prior to 3.15 (upstream kernel
      commit 2796d0c648c940b4796f84384fbcfb0a2399db84 "bridge: Automatically
      manage port promiscuous mode"). Even after that, until kernel 3.17
      (upstream commit 5be5a2df40f005ea7fb7e280e87bbbcfcf1c2fc0 "bridge: Add
      filtering support for default_pvid") traffic will not be properly
      forwarded without manually adding vlan table entries. Unfortunately,
      although the presence of the first patch is signalled by existence of
      the "learning" and "unicast_flood" options in sysfs, there is no
      reliable way to query whether or not the system's kernel has the
      second of those patches installed, the only thing that can be done is
      to try the setting and see if traffic continues to pass.
      7cb822c2
    • E
      getstats: add block.n.path stat · 7b499262
      Eric Blake 提交于
      I'm about to make block stats optionally more complex to cover
      backing chains, where block.count will no longer equal the number
      of <disks> for a domain.  For these reasons, it is nicer if the
      statistics output includes the source path (for local files).
      This patch doesn't add anything for network disks, although we
      may decide to add that later.
      
      With this patch, I now see the following for the same domain as
      in the previous patch (one qcow2 file, and an empty cdrom drive):
      $ virsh domstats --block foo
      Domain: 'foo'
        block.count=2
        block.0.name=hda
        block.0.path=/var/lib/libvirt/images/foo.qcow2
        block.1.name=hdc
      
      * src/libvirt-domain.c (virConnectGetAllDomainStats): Document
      new field.
      * tools/virsh.pod (domstats): Document new field.
      * src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Return the new
      stat for local files/block devices.
      (QEMU_ADD_NAME_PARAM): Add parameter.
      (qemuDomainGetStatsInterface): Update caller.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7b499262
    • E
      getstats: start giving offline block stats · 56b21dfe
      Eric Blake 提交于
      I noticed that for an offline domain, 'virsh domstats --block $dom'
      was producing just the domain name, with no stats.  But the older
      'virsh domblkinfo' works just fine on offline domains.  This patch
      starts to get us closer, by at least reporting the disk names for
      an offline domain.
      
      With this patch, I now see the following for an offline domain
      with one qcow2 disk and an empty cdrom drive:
      $ virsh domstats --block foo
      Domain: 'foo'
        block.count=2
        block.0.name=hda
        block.1.name=hdc
      
      * src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Don't short-circuit
      output of block name.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      56b21dfe
    • E
      getstats: avoid memory leak on OOM · 2f61602e
      Eric Blake 提交于
      qemuDomainGetStatsBlock() could leak a stats hash table if it
      encountered OOM while populating the virTypedParameters.
      Oddly, the fix doesn't even touch qemuDomainGetStatsBlock :)
      
      * src/qemu/qemu_driver.c (QEMU_ADD_COUNT_PARAM)
      (QEMU_ADD_NAME_PARAM): Don't return early.
      (qemuDomainGetStatsInterface): Adjust caller.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2f61602e
  8. 05 12月, 2014 2 次提交
    • D
      Report original error when QMP probing fails with new QEMU · 25bf888a
      Daniel P. Berrange 提交于
      If probing capabilities via QMP fails, we now have a check
      that prevents us falling back to -help parsing. Unfortunately
      the error message
      
        "Failed to probe capabilities for /usr/bin/qemu-kvm:
         unsupported configuration: QEMU 2.1.2 is too new for help parsing"
      
      is proving rather unhelpful to the user. We need to be telling
      them why QMP failed (the root cause), rather than they can't
      use -help (the side effect).
      
      To do this we should capture stderr during QMP probing, and
      if -help parsing then sees a new QEMU version, we know that
      QMP should have worked, and so we can show the messages from
      stderr. The message thus becomes
      
        "Failed to probe capabilities for /usr/bin/qemu-kvm:
         internal error: QEMU / QMP failed: Could not access
         KVM kernel module: No such file or directory
         failed to initialize KVM: No such file or directory"
      25bf888a
    • S
      qemu: snapshot: Forbid internal snapshot with passthrough devices · d1e46013
      Shanzhi Yu 提交于
      When attempting to create internal system checkpoint with a passthrough
      device qemu will report the following error:
      
      error: operation failed: Error -22 while writing VM
      
      This patch calls the function to check if migration is possible with
      given VM and thus improves the error to:
      
      error: Requested operation is not valid: domain has assigned non-USB host devices
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418#c19Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      d1e46013
  9. 04 12月, 2014 4 次提交
    • P
      qemu: process: Avoid uninitialized use two vars when reconnecting to vm · 38bde577
      Peter Krempa 提交于
      3ecebf07 breaks the build as it adds a
      way to jump to cleanup before the 'cfg' object is retrieved and 'priv'
      is initialized.
      38bde577
    • P
      qemu: process: Refactor reconnecting to qemu processes · 3ecebf07
      Peter Krempa 提交于
      Move entering the job into the thread to simplify the program flow. Also
      as the code holds a separate reference to the domain object some
      conditions can be simplified.
      
      After this patch qemuDomainObjTransferJob is no longer needed so this
      patch removes it.
      3ecebf07
    • E
      qemu: Fix virsh freeze when blockcopy storage file is removed · fe3691f6
      Erik Skultety 提交于
      If someone removes blockcopy storage file when still in mirroring phase
      and then requesting blockjob abort using pivot, virsh cmd freezes. This
      is not an issue with older qemu versions which did not support
      asynchronous jobs (which we prefer by default).
      As we have reached the mirroring phase successfully, polling monitor for
      blockjob info always returns 1 and the loop never ends.
      This fix introduces a check for qemuDomainBlockPivot return code, possibly
      skipping the asynchronous waiting completely, if an error occurred and
      asynchronous waiting was the preferred method.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1139567
      fe3691f6
    • P
      qemu: driver: Reload snapshots and managedsaves prior to reconnecting · 48a05560
      Peter Krempa 提交于
      Reconnect to the VM is a possibly long-running job spawned in a separate
      thread. We should reload the snapshot defs and managedsave state prior
      to spawning the thread to avoid blocking of the daemon startup which
      would serialize on the VM lock.
      
      Also the reloading code would violate the domain job held while
      reconnecting as the loader functions don't create jobs.
      48a05560
  10. 03 12月, 2014 6 次提交
    • M
      qemu_migration: Precreate missing storage · cf54c606
      Michal Privoznik 提交于
      Based on previous commit, we can now precreate missing volumes. While
      digging out the functionality from storage driver would be nicer, if
      you've seen the code it's nearly impossible. So I'm going from the
      other end:
      
      1) For given disk target, disk path is looked up.
      2) For the disk path, storage pool is looked up, a volume XML is
      constructed and then passed to virStorageVolCreateXML() which has all
      the knowledge how to create raw images, (encrypted) qcow(2) images,
      etc.
      
      One of the advantages of this approach is, we don't have to care about
      image conversion - qemu does that for us. So for instance, users can
      transform qcow2 into raw on migration (if the correct XML is passed to
      the migration API).
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      cf54c606
    • M
      qemu_migration: Send disk sizes to the other side · e1466dc7
      Michal Privoznik 提交于
      Up 'til now, users need to precreate non-shared storage on migration
      themselves. This is not very friendly requirement and we should do
      something about it. In this patch, the migration cookie is extended,
      so that <nbd/> section does not only contain NBD port, but info on
      disks being migrated. This patch sends a list of pairs of:
      
          <disk target; disk size>
      
      to the destination. The actual storage allocation is left for next
      commit.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      e1466dc7
    • M
      qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks · a714533b
      Michal Privoznik 提交于
      The function queries the block devices visible to qemu
      ('query-block') and parses the qemu's output. The info is
      returned in a hash table which is expected to be pre-filled by
      qemuMonitorJSONGetAllBlockStatsInfo(). However, in the next patch
      we are not going to call the latter function at all, so we should
      make the former function add devices into the hash table if not
      found there.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      a714533b
    • J
      Replace virDomainSnapshotFree with virObjectUnref · c8230c4d
      John Ferlan 提交于
      Since virDomainSnapshotFree will call virObjectUnref anyway, let's just use
      that directly so as to avoid the possibility that we inadvertently clear out
      a pending error message when using the public API.
      c8230c4d
    • J
      Replace virNetworkFree with virObjectUnref · 121c09a9
      John Ferlan 提交于
      Since virNetworkFree will call virObjectUnref anyway, let's just use that
      directly so as to avoid the possibility that we inadvertently clear out
      a pending error message when using the public API.
      121c09a9
    • J
      Replace virDomainFree with virObjectUnref · 8fb3aee2
      John Ferlan 提交于
      Since virDomainFree will call virObjectUnref anyway, let's just use that
      directly so as to avoid the possibility that we inadvertently clear out
      a pending error message when using the public API.
      8fb3aee2
  11. 02 12月, 2014 1 次提交