1. 19 2月, 2014 1 次提交
  2. 18 2月, 2014 1 次提交
    • M
      network: Introduce network hooks · f1ab06e4
      Michal Privoznik 提交于
      There might be some use cases, where user wants to prepare the host or
      its environment prior to starting a network and do some cleanup after
      the network has been shut down. Consider all the functionality that
      libvirt doesn't currently have as an example what a hook script can
      possibly do.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      f1ab06e4
  3. 17 2月, 2014 1 次提交
    • M
      qemu: Implement VIR_DOMAIN_TAINT_HOOK · 3b2c2794
      Michal Privoznik 提交于
      Currently, there's just one place where we care if hook script is
      changing the domain XML: migration hook for incoming migration. In
      all other places where a hook script is executed, we don't read the
      XML back from the script.
      
      Anyway, the hook script can alter domain XML and hence we should taint
      it if the script did.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      3b2c2794
  4. 14 2月, 2014 5 次提交
  5. 11 2月, 2014 5 次提交
    • P
      Handle non-sequential NUMA node numbers · cd921cf0
      Pradipta Kr. Banerjee 提交于
      On some platforms like IBM PowerNV the NUMA node numbers can be
      non-sequential. For eg. numactl --hardware o/p from such a machine looks
      as given below
      
      node distances:
         node   0   1  16  17
           0:  10  40  40  40
           1:  40  10  40  40
          16:  40  40  10  40
          17:  40  40  40  10
      
      The NUMA nodes are 0,1,16,17
      
      Libvirt uses sequential index as NUMA node numbers and this can
      result in crash or incorrect results.
      Signed-off-by: NShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
      Signed-off-by: NPradipta Kr. Banerjee <bpradip@in.ibm.com>
      cd921cf0
    • M
      qemu: introduce spiceport chardev backend · d27e6bc4
      Martin Kletzander 提交于
      Add a new backend for any character device.  This backend uses channel
      in spice connection.  This channel is similar to spicevmc, but
      all-purpose in contrast to spicevmc.
      
      Apart from spicevmc, spiceport-backed chardev will not be formatted
      into the command-line if there is no spice to use (with test for that
      as well).  For this I moved the def->graphics counting to the start
      of the function so its results can be used in rest of the code even in
      the future.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      d27e6bc4
    • M
      qemu: remove pointless condition · 296a4791
      Martin Kletzander 提交于
      This patch is here just to ease the code review and make related
      changes look more sensible.  Apart from removing the condition this is
      merely a whitespace (indentation) change.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      296a4791
    • M
      qemu: rework '-serial none' · a53e5040
      Martin Kletzander 提交于
      Limiting ourselves to qemu without QEMU_CAPS_DEVICE capability, we
      used '-serial none' only if there was no serial device defined in the
      domain XML.  This means that if we want to have a possibility of the
      device being defined in XML, but not used in the command-line
      (e.g. when it's pointless), we'll fail to attach '-serial none' to the
      command-line (when skipping the device's command-line building and the
      device being the only one).
      
      Since there is no such device, this patch doesn't actually do
      anything, but enables easier future additions in this manner.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      a53e5040
    • M
      conf: introduce spiceport chardev backend · 5b189541
      Martin Kletzander 提交于
      Add a new character device backend called 'spiceport' that uses
      spice's channel for communications and apart from spicevmc can be used
      as a backend for any character device from libvirt's point of view.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      5b189541
  6. 10 2月, 2014 3 次提交
    • P
      qemu: Use correct permissions when determining the image chain · 9bf629ab
      Peter Krempa 提交于
      The code took into account only the global permissions. The domains now
      support per-vm DAC labels and per-image DAC labels. Use the most
      specific label available.
      9bf629ab
    • P
      qemu: hyperv: Add support for timer enlightenments · 600bca59
      Peter Krempa 提交于
      Add a new <timer> for the HyperV reference time counter enlightenment
      and the iTSC reference page for Windows guests.
      
      This feature provides a paravirtual approach to track timer events for
      the guest (similar to kvmclock) with the option to use real hardware
      clock on systems with a iTSC with compensation across various hosts.
      600bca59
    • P
      conf: Enforce supported options for certain timers · 8ffaa42d
      Peter Krempa 提交于
      According to the documentation various timer options are only supported
      by certain timer types. Add a post parse check to verify that the user
      didn't specify invalid options.
      
      Also fix the qemu command line parsing function to set correct default
      values for the kvmclock timer so that it passes the new check.
      8ffaa42d
  7. 07 2月, 2014 2 次提交
  8. 06 2月, 2014 4 次提交
  9. 05 2月, 2014 1 次提交
    • E
      event: move event filtering to daemon (regression fix) · 11f20e43
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1058839
      
      Commit f9f56340 for CVE-2014-0028 almost had the right idea - we
      need to check the ACL rules to filter which events to send.  But
      it overlooked one thing: the event dispatch queue is running in
      the main loop thread, and therefore does not normally have a
      current virIdentityPtr.  But filter checks can be based on current
      identity, so when libvirtd.conf contains access_drivers=["polkit"],
      we ended up rejecting access for EVERY event due to failure to
      look up the current identity, even if it should have been allowed.
      
      Furthermore, even for events that are triggered by API calls, it
      is important to remember that the point of events is that they can
      be copied across multiple connections, which may have separate
      identities and permissions.  So even if events were dispatched
      from a context where we have an identity, we must change to the
      correct identity of the connection that will be receiving the
      event, rather than basing a decision on the context that triggered
      the event, when deciding whether to filter an event to a
      particular connection.
      
      If there were an easy way to get from virConnectPtr to the
      appropriate virIdentityPtr, then object_event.c could adjust the
      identity prior to checking whether to dispatch an event.  But
      setting up that back-reference is a bit invasive.  Instead, it
      is easier to delay the filtering check until lower down the
      stack, at the point where we have direct access to the RPC
      client object that owns an identity.  As such, this patch ends
      up reverting a large portion of the framework of commit f9f56340.
      We also have to teach 'make check' to special-case the fact that
      the event registration filtering is done at the point of dispatch,
      rather than the point of registration.  Note that even though we
      don't actually use virConnectDomainEventRegisterCheckACL (because
      the RegisterAny variant is sufficient), we still generate the
      function for the purposes of documenting that the filtering
      takes place.
      
      Also note that I did not entirely delete the notion of a filter
      from object_event.c; I still plan on using that for my upcoming
      patch series for qemu monitor events in libvirt-qemu.so.  In
      other words, while this patch changes ACL filtering to live in
      remote.c and therefore we have no current client of the filtering
      in object_event.c, the notion of filtering in object_event.c is
      still useful down the road.
      
      * src/check-aclrules.pl: Exempt event registration from having to
      pass checkACL filter down call stack.
      * daemon/remote.c (remoteRelayDomainEventCheckACL)
      (remoteRelayNetworkEventCheckACL): New functions.
      (remoteRelay*Event*): Use new functions.
      * src/conf/domain_event.h (virDomainEventStateRegister)
      (virDomainEventStateRegisterID): Drop unused parameter.
      * src/conf/network_event.h (virNetworkEventStateRegisterID):
      Likewise.
      * src/conf/domain_event.c (virDomainEventFilter): Delete unused
      function.
      * src/conf/network_event.c (virNetworkEventFilter): Likewise.
      * src/libxl/libxl_driver.c: Adjust caller.
      * src/lxc/lxc_driver.c: Likewise.
      * src/network/bridge_driver.c: Likewise.
      * src/qemu/qemu_driver.c: Likewise.
      * src/remote/remote_driver.c: Likewise.
      * src/test/test_driver.c: Likewise.
      * src/uml/uml_driver.c: Likewise.
      * src/vbox/vbox_tmpl.c: Likewise.
      * src/xen/xen_driver.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      11f20e43
  10. 04 2月, 2014 1 次提交
    • L
      qemu: be sure we're using the updated value of backend during hotplug · 0d0a7bf4
      Laine Stump 提交于
      commit f094aaac changed qemuPrepareHostdevPCIDevices() such that it
      may modify the "backend" (vfio vs. legacy kvm) setting in the
      virHostdevDef. However, qemuDomainAttachHostPciDevice() (used by
      hotplug) copies the backend setting into a local *before* calling
      qemuPrepareHostdevPCIDevices(), and then later makes a decision based
      on that pre-change value.
      
      The result is that, if the backend had been set to "default" (i.e. not
      specified in the config) and was later updated to "VFIO" by
      qemuPrepareHostdevPCIDevices(), the qemu process' MacMemLock is not
      increased (as is required for VFIO device assignment).
      
      This patch delays making the local copy of backend until after its
      potential modification.
      0d0a7bf4
  11. 03 2月, 2014 1 次提交
  12. 31 1月, 2014 1 次提交
    • D
      Push nwfilter update locking up to top level · 6e5c79a1
      Daniel P. Berrange 提交于
      The NWFilter code has as a deadlock race condition between
      the virNWFilter{Define,Undefine} APIs and starting of guest
      VMs due to mis-matched lock ordering.
      
      In the virNWFilter{Define,Undefine} codepaths the lock ordering
      is
      
        1. nwfilter driver lock
        2. virt driver lock
        3. nwfilter update lock
        4. domain object lock
      
      In the VM guest startup paths the lock ordering is
      
        1. virt driver lock
        2. domain object lock
        3. nwfilter update lock
      
      As can be seen the domain object and nwfilter update locks are
      not acquired in a consistent order.
      
      The fix used is to push the nwfilter update lock upto the top
      level resulting in a lock ordering for virNWFilter{Define,Undefine}
      of
      
        1. nwfilter driver lock
        2. nwfilter update lock
        3. virt driver lock
        4. domain object lock
      
      and VM start using
      
        1. nwfilter update lock
        2. virt driver lock
        3. domain object lock
      
      This has the effect of serializing VM startup once again, even if
      no nwfilters are applied to the guest. There is also the possibility
      of deadlock due to a call graph loop via virNWFilterInstantiate
      and virNWFilterInstantiateFilterLate.
      
      These two problems mean the lock must be turned into a read/write
      lock instead of a plain mutex at the same time. The lock is used to
      serialize changes to the "driver->nwfilters" hash, so the write lock
      only needs to be held by the define/undefine methods. All other
      methods can rely on a read lock which allows good concurrency.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6e5c79a1
  13. 30 1月, 2014 3 次提交
    • O
      qemu: Fix the error message for scsi host device's shareable checking · f406aa25
      Osier Yang 提交于
      This fixes the wrong argument order.
      f406aa25
    • O
      util: Add one argument for several scsi utils · 10c9ceff
      Osier Yang 提交于
      To support passing the path of the test data to the utils, one
      more argument is added to virSCSIDeviceGetSgName,
      virSCSIDeviceGetDevName, and virSCSIDeviceNew, and the related
      code is changed accordingly.
      
      Later tests for the scsi utils will be based on this patch.
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      10c9ceff
    • O
      qemu: Don't fail if the SCSI host device is shareable between domains · fd243fc4
      Osier Yang 提交于
      It doesn't make sense to fail if the SCSI host device is specified
      as "shareable" explicitly between domains (NB, it works if and only
      if the device is specified as "shareable" for *all* domains,
      otherwise it fails).
      
      To fix the problem, this patch introduces an array for virSCSIDevice
      struct, which records all the names of domain which are using the
      device (note that the recorded domains must specify the device as
      shareable).  And the change on the data struct brings on many
      subsequent changes in the code.
      
      Prior to this patch, the "shareable" tag didn't work as expected,
      it actually work like "non-shareable".  So this patch also added notes
      in formatdomain.html to declare the fact.
      
      * src/util/virscsi.h:
        - Remove virSCSIDeviceGetUsedBy
        - Change definition of virSCSIDeviceGetUsedBy and virSCSIDeviceListDel
        - Add virSCSIDeviceIsAvailable
      
      * src/util/virscsi.c:
        - struct virSCSIDevice: Change "used_by" to be an array; Add
          "n_used_by" as the array count
        - virSCSIDeviceGetUsedBy: Removed
        - virSCSIDeviceFree: frees the "used_by" array
        - virSCSIDeviceSetUsedBy: Copy the domain name to avoid potential
          memory corruption
        - virSCSIDeviceIsAvailable: New
        - virSCSIDeviceListDel: Change the logic, for device which is already
          in the list, just remove the corresponding entry in "used_by". And
          since it's only used in one place, we can safely removing the code
          to find out the dev in the list first.
        - Copyright updating
      
      * src/libvirt_private.sys:
        - virSCSIDeviceGetUsedBy: Remove
        - virSCSIDeviceIsAvailable: New
      
      * src/qemu/qemu_hostdev.c:
        - qemuUpdateActiveScsiHostdevs: Check if the device existing before
          adding it to the list;
        - qemuPrepareHostdevSCSIDevices: Error out if the not all domains
          use the device as "shareable"; Also don't try to add the device
          to the activeScsiHostdevs list if it already there; And make
          more sensible error w.r.t the current "shareable" value in
          driver->activeScsiHostdevs.
        - qemuDomainReAttachHostScsiDevices: Change the logic according
          to the changes on helpers.
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      fd243fc4
  14. 29 1月, 2014 1 次提交
    • P
      snapshot: Add support for specifying snapshot disk backing type · 7076b4b7
      Peter Krempa 提交于
      Add support for specifying various types when doing snapshots. This will
      later allow to do snapshots on network backed volumes. Disks of type
      'volume' are not supported by snapshots (yet).
      
      Also amend the test suite to check parsing of the various new disk
      types that can now be specified.
      7076b4b7
  15. 28 1月, 2014 1 次提交
  16. 25 1月, 2014 1 次提交
    • J
      Block info query: Add check for transient domain · 46a0737e
      John Ferlan 提交于
      Currently the qemuDomainGetBlockInfo will return allocation == physical
      for most backing stores. For a qcow2 block backed device it's possible
      to return the highest lv extent allocated from qemu for an active guest.
      That is a value where allocation != physical and one would hope be less.
      However, if the guest is not running, then the code falls back to returning
      allocation == physical. This turns out to be problematic for rhev which
      monitors the size of the backing store. During a migration, before the
      VM has been started on the target and while it is deemed inactive on the
      source, there's a small window of time where the allocation is returned
      as physical triggering the code to extend the file unnecessarily.
      
      Since rhev uses transient domains and this is edge condition for a transient
      domain, rather than returning good status and allocation == physical when
      this "window of opportunity" exists, this patch will check for a transient
      (or non persistent) domain and return a failure to the caller rather than
      returning the defaults. For a persistent domain, the defaults will be
      returned. The description for the virDomainGetBlockInfo has been updated
      to describe the phenomena.
      46a0737e
  17. 24 1月, 2014 1 次提交
  18. 23 1月, 2014 2 次提交
    • O
      util: Add "shareable" field for virSCSIDevice struct · 2b66504d
      Osier Yang 提交于
      Unlike the host devices of other types, SCSI host device XML supports
      "shareable" tag. This patch introduces it for the virSCSIDevice struct
      for a later patch use (to detect if the SCSI device is shareable when
      preparing the SCSI host device in QEMU driver).
      2b66504d
    • E
      api: require write permission for guest agent interaction · 7f2d27d1
      Eric Blake 提交于
      I noticed that we allow virDomainGetVcpusFlags even for read-only
      connections, but that with a flag, it can require guest agent
      interaction.  It is feasible that a malicious guest could
      intentionally abuse the replies it sends over the guest agent
      connection to possibly trigger a bug in libvirt's JSON parser,
      or withhold an answer so as to prevent the use of the agent
      in a later command such as a shutdown request.  Although we
      don't know of any such exploits now (and therefore don't mind
      posting this patch publicly without trying to get a CVE assigned),
      it is better to err on the side of caution and explicitly require
      full access to any domain where the API requires guest interaction
      to operate correctly.
      
      I audited all commands that are marked as conditionally using a
      guest agent.  Note that at least virDomainFSTrim is documented
      as needing a guest agent, but that such use is unconditional
      depending on the hypervisor (so the existing domain:fs_trim ACL
      should be sufficient there, rather than also requirng domain:write).
      But when designing future APIs, such as the plans for obtaining
      a domain's IP addresses, we should copy the approach of this patch
      in making interaction with the guest be specified via a flag, and
      use that flag to also require stricter access checks.
      
      * src/libvirt.c (virDomainGetVcpusFlags): Forbid guest interaction
      on read-only connection.
      (virDomainShutdownFlags, virDomainReboot): Improve docs on agent
      interaction.
      * src/remote/remote_protocol.x
      (REMOTE_PROC_DOMAIN_SNAPSHOT_CREATE_XML)
      (REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
      (REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS, REMOTE_PROC_DOMAIN_REBOOT)
      (REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS): Require domain:write for any
      conditional use of a guest agent.
      * src/xen/xen_driver.c: Fix clients.
      * src/libxl/libxl_driver.c: Likewise.
      * src/uml/uml_driver.c: Likewise.
      * src/qemu/qemu_driver.c: Likewise.
      * src/lxc/lxc_driver.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7f2d27d1
  19. 22 1月, 2014 2 次提交
  20. 21 1月, 2014 3 次提交
    • P
      qemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting · 55bbb011
      Peter Krempa 提交于
      We shouldn't access the domain definition while we are in the monitor
      section as the domain is unlocked. Additionally after we exit from the
      monitor we need to check if the VM is still alive. Not doing so resulted
      in a crash if qemu exits while attempting to do an external VM snapshot.
      55bbb011
    • F
      spice: expose the QEMU disable file transfer option · 08d07e5f
      Francesco Romani 提交于
      spice-server offers an API to disable file transfer messages
      on the agent channel between the client and the guest.
      This is supported in qemu through the disable-agent-file-xfer option.
      
      This patch exposes this option to libvirt.
      Adds a new element 'filetransfer', with one property,
      'enable', which accepts a boolean.
      Default is enabled, for backward compatibility.
      
      Depends on the capability exported in the first patch of the series.
      Signed-off-by: NFrancesco Romani <fromani@redhat.com>
      08d07e5f
    • F
      spice: detect if qemu can disable file transfer · 19bbc812
      Francesco Romani 提交于
      spice-server offers an API to disable file transfer messages
      on the agent channel between the client and the guest.
      This is supported in qemu through the disable-agent-file-xfer option.
      
      This patch detects if QEMU supports this option, and add
      a capability if does.
      Signed-off-by: NFrancesco Romani <fromani@redhat.com>
      19bbc812