1. 14 11月, 2012 1 次提交
    • P
      snapshot: qemu: Fix detection of external snapshots when deleting · 30f1bccf
      Peter Krempa 提交于
      This patch adds a helper to determine if snapshots are external and uses
      the helper to fix detection of those in snapshot deletion code.
      
      Snapshots are external if they have an external memory image or if the
      disk locations are external. As mixed snapshots are forbidden for now
      we need to check just one disk to know.
      30f1bccf
  2. 12 11月, 2012 1 次提交
    • M
      qemu: Allow migration to be cancelled at prepare phase · ab5e7d49
      Michal Privoznik 提交于
      Currently, if user calls virDomainAbortJob we just issue
      'migrate_cancel' and hope for the best. However, if user calls
      the API in wrong phase when migration hasn't been started yet
      (perform phase) the cancel request is just ignored. With this
      patch, the request is remembered and as soon as perform phase
      starts, migration is cancelled.
      ab5e7d49
  3. 09 11月, 2012 1 次提交
    • P
      qemu: Fix domain ID numbering race condition · 02cf57c0
      Peter Krempa 提交于
      When the libvirt daemon is restarted it tries to reconnect to running
      qemu domains. Since commit d38897a5 the
      re-connection code runs in separate threads. In the original
      implementation the maximum of domain ID's (that is used as an
      initializer for numbering guests created next) while libvirt was
      reconnecting to the guest.
      
      With the threaded implementation this opens a possibility for race
      conditions with the thread that is autostarting guests. When there's a
      guest running with id 1 and the daemon is restarted. The autostart code
      is reached first and spawns the first guest that should be autostarted
      as id 1. This results into the following unwanted situation:
      
       # virsh list
         Id    Name                           State
        ----------------------------------------------------
         1     guest1                         running
         1     guest2                         running
      
      This patch extracts the detection code before the re-connection threads
      are started so that the maximum id of the guests being reconnected to is
      known.
      
      The only semantic change created by this is if the guest with greatest ID
      quits before we are able to reconnect it's ID is used anyway as the
      greatest one as without this patch the greatest ID of a process we could
      successfuly reconnect to would be used.
      02cf57c0
  4. 08 11月, 2012 2 次提交
    • P
      qemu: Fix function header formating of 2 functions · e124f498
      Peter Krempa 提交于
      Headers of qemuDomainSnapshotLoad and qemuDomainNetsRestart were
      improperly formatted.
      e124f498
    • P
      snapshot: qemu: Add support for external inactive snapshots · 9b5a514b
      Peter Krempa 提交于
      This patch adds support for external disk snapshots of inactive domains.
      The snapshot is created by calling using qemu-img by calling:
      
       qemu-img create -f format_of_snapshot -o
       backing_file=/path/to/src,backing_fmt=format_of_backing_image
       /path/to/snapshot
      
      in case the backing image format is known or probing is allowed and
      otherwise:
      
       qemu-img create -f format_of_snapshot -o  backing_file=/path/to/src
       /path/to/snapshot
      
      on each of the disks selected for snapshotting. This patch also modifies
      the snapshot preparing function to support creating external snapshots
      and to sanitize arguments. For now the user isn't able to mix external
      and internal snapshots but this restriction might be lifted in the
      future.
      9b5a514b
  5. 07 11月, 2012 1 次提交
    • M
      qemu: Emit event if 'cont' fails · a08fc66d
      Michal Privoznik 提交于
      Some operations, APIs needs domain to be paused prior operation can be
      performed, e.g. (managed-) save of a domain. The processors should be
      restored in the end. However, if 'cont' fails for some reason, we log a
      message but this is not sufficient as an event should be emitted as
      well. Mgmt application can then decide what to do.
      a08fc66d
  6. 06 11月, 2012 1 次提交
    • P
      qemu: Don't corrupt pointer in qemuDomainSaveMemory() · fb58f8e2
      Peter Krempa 提交于
      The code that was split out into the qemuDomainSaveMemory expands the
      pointer containing the XML description of the domain that it gets from
      higher layers. If the pointer changes the old one is invalid and the
      upper layer function tries to free it causing an abort.
      
      This patch changes the expansion of the original string to a new
      allocation and copy of the contents.
      fb58f8e2
  7. 05 11月, 2012 1 次提交
  8. 04 11月, 2012 1 次提交
    • P
      snapshot: qemu: Add support for external checkpoints · f569b87f
      Peter Krempa 提交于
      This patch adds support to take external system checkpoints.
      
      The functionality is layered on top of the previous disk-only snapshot
      code. When the checkpoint is requested the domain memory is saved to the
      memory image file using migration to file. (The user may specify to
      take the memory image while the guest is live with the
      VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag.)
      
      The memory save image shares format with the image created by
      virDomainSave() API.
      f569b87f
  9. 03 11月, 2012 6 次提交
    • P
      snapshot: qemu: Rename qemuDomainSnapshotCreateActive · b5fd4044
      Peter Krempa 提交于
      Before now, libvirt supported only internal snapshots for active guests.
      This patch renames this function to qemuDomainSnapshotCreateActiveInternal
      to prepare the grounds for external active snapshots.
      b5fd4044
    • P
      qemu: Split out domain memory saving code to allow reuse · 2771f8b7
      Peter Krempa 提交于
      The code that saves domain memory by migration to file can be reused
      while doing external checkpoints of a machine. This patch extracts the
      common code and places it in a separate function.
      2771f8b7
    • P
      qemu: Clean up snapshot retrieval to use the new helper · ec69ca14
      Peter Krempa 提交于
      Two other places were left with the old code to look up snapshots.
      Change them to use the snapshot lookup helper.
      ec69ca14
    • P
      qemu: Fix possible race when pausing guest · d0fc6dc8
      Peter Krempa 提交于
      When pausing the guest while migration is running (to speed up
      convergence) the virDomainSuspend API checks if the migration job is
      active before entering the job. This could cause a possible race if the
      virDomainSuspend is called while the job is active but ends before the
      Suspend API enters the job (this would require that the migration is
      aborted). This would cause a incorrect event to be emitted.
      d0fc6dc8
    • E
      snapshot: merge pre-snapshot checks · de76cae9
      Eric Blake 提交于
      Both system checkpoint snapshots and disk snapshots were iterating
      over all disks, doing a final sanity check before doing any work.
      But since future patches will allow offline snapshots to be either
      external or internal, it makes sense to share the pass over all
      disks, and then relax restrictions in that pass as new modes are
      implemented.  Future patches can then handle external disks when
      the domain is offline, then handle offline --disk-snapshot, and
      finally, combine with migration to file to gain a complete external
      system checkpoint snapshot of an active domain without using 'savevm'.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
      (qemuDomainSnapshotIsAllowed): Merge...
      (qemuDomainSnapshotPrepare): ...into one function.
      (qemuDomainSnapshotCreateXML): Update caller.
      de76cae9
    • E
      snapshot: populate new XML info for qemu snapshots · e260e401
      Eric Blake 提交于
      Now that the XML supports listing internal snapshots, it is worth
      always populating the <memory> and <disks> element to match.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Always
      parse disk info and set memory info.
      e260e401
  10. 02 11月, 2012 2 次提交
  11. 01 11月, 2012 1 次提交
    • E
      build: prefer mkostemp for multi-thread safety · 4dbd6e96
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=871756
      
      Commit cd1e8d1c assumed that systems new enough to have journald
      also have mkostemp; but this is not true for uclibc.
      
      For that matter, use of mkstemp[s] is unsafe in a multi-threaded
      program.  We should prefer mkostemp[s] in the first place.
      
      * bootstrap.conf (gnulib_modules): Add mkostemp, mkostemps; drop
      mkstemp and mkstemps.
      * cfg.mk (sc_prohibit_mkstemp): New syntax check.
      * tools/virsh.c (vshEditWriteToTempFile): Adjust caller.
      * src/qemu/qemu_driver.c (qemuDomainScreenshot)
      (qemudDomainMemoryPeek): Likewise.
      * src/secret/secret_driver.c (replaceFile): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
      4dbd6e96
  12. 31 10月, 2012 1 次提交
  13. 30 10月, 2012 1 次提交
    • M
      qemu: Report errors from iohelper · 34e8f63a
      Michal Privoznik 提交于
      Currently, we use iohelper when saving/restoring a domain.
      However, if there's some kind of error (like I/O) it is not
      propagated to libvirt. Since it is not qemu who is doing
      the actual write() it will not get error. The iohelper does.
      Therefore we should check for iohelper errors as it makes
      libvirt more user friendly.
      34e8f63a
  14. 28 10月, 2012 1 次提交
  15. 27 10月, 2012 10 次提交
    • E
      blockjob: relabel entire existing chain · 5a3501be
      Eric Blake 提交于
      When using block copy to pivot over to a new chain, the backing files
      for the new chain might still need labeling (particularly if the user
      passes --reuse-ext with a relative backing file name).  Relabeling a
      file that is already labeled won't hurt, so this just labels the entire
      chain at the point of the pivot.  Doing the relabel of the chain uses
      the fact that we already safely probed the file type of an external
      file at the start of the block copy.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockPivot): Relabel chain before
      asking qemu to pivot.
      5a3501be
    • E
      blockjob: allow mirroring under SELinux and cgroup · 35c7701c
      Eric Blake 提交于
      Use the recent addition of qemuDomainPrepareDiskChainElement to
      obtain locking manager lease, permit a block device through cgroups,
      and set the SELinux label; then audit the fact that we hand a new
      file over to qemu.  Alas, releasing the lease and label at the end
      of the mirroring is a trickier prospect (we would have to trace the
      backing chain of both source and destination, and be sure not to
      revoke rights to any part of the chain that is shared), so for now,
      virDomainBlockJobAbort still leaves things with additional access
      granted (as block-pull and block-commit have the same problem of
      not clamping access after completion, a future cleanup would cover
      all three commands).
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set up labeling.
      35c7701c
    • E
      blockjob: allow for existing files in block-copy · 8ee5073c
      Eric Blake 提交于
      Support the REUSE_EXT flag, in part by copying sanity checks from
      snapshot code.  This code introduces a case of probing an external
      file for its type; such an action would be a security risk if the
      existing file is supposed to be raw but the contents resemble some
      other format; however, since the virDomainBlockRebase API has a
      flag to force treating the file as raw rather than probe, we can
      assume that probing is safe in all other instances.  Besides, if
      we don't probe or force raw, then qemu will.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockRebase): Allow REUSE_EXT
      flag.
      (qemuDomainBlockCopy): Wire up flag, and add some sanity checks.
      8ee5073c
    • E
      blockjob: implement block copy for qemu · c1eb3805
      Eric Blake 提交于
      Minimal patch to wire up all the pieces in the previous patches
      to actually enable a block copy job.  By minimal, I mean that
      qemu creates the file (that is, no REUSE_EXT flag support yet),
      SELinux must be disabled, a lock manager is not informed, and the
      audit logs aren't updated.  But those will be added as
      improvements in future patches.
      
      This patch is designed so that if we ever add a future API
      virDomainBlockCopy with more bells and whistles (such as letting
      the user specify a destination image format different than the
      source), where virDomainBlockRebase is a wrapper around the
      simpler portions of the new functionality, then the new API can
      just reuse the new qemuDomainBlockCopy function and already
      support _SHALLOW and _REUSE_EXT flags.  Also note that libvirt.c
      already filtered the new flags if _COPY is not present, so that
      we are not impacting the case of BlockRebase being a wrapper
      around BlockPull.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCopy): New function.
      (qemuDomainBlockRebase): Call it when appropriate.
      c1eb3805
    • E
      blockjob: make block pivot safer · 400ac797
      Eric Blake 提交于
      Since libvirt drops locks between issuing a monitor command and
      getting a response, it is possible for libvirtd to be restarted
      before getting a response on a block-job-complete command; worse, it
      is also possible for the guest to shut itself down during the window
      while libvirtd is down, ending the qemu process.  A management app
      needs to know if the pivot happened (and the destination file
      contains guest contents not in the source) or failed (and the source
      file contains guest contents not in the destination), but since
      the job is finished, 'query-block-jobs' no longer tracks the
      status of the job, and if the qemu process itself has disappeared,
      even 'query-block' cannot be checked to ask qemu its current state.
      
      At the time of this patch, the design for persistent bitmap has not
      been clarified, so a followup patch will be needed once qemu
      actually figures out how to expose it, and we figure out how to use
      it.  In the meantime, we have a solution that avoids the worst of
      the problem.  [This problem was first analyzed with the RHEL 6.3
      __com.redhat_drive-reopen command; which partly explains why
      upstream qemu 1.3 ditched the drive-reopen idea and went with
      block-job-complete plus persistent bitmap instead.]
      
      If we surround 'drive-reopen' with a pause/resume pair, then we can
      guarantee that the guest cannot modify either source or destination
      files in the window of libvirtd uncertainty, and the management app
      is guaranteed that either libvirt knows the outcome and reported it
      correctly; or that on libvirtd restart, the guest will still be
      paused and that the qemu process cannot have disappeared due to
      guest shutdown; and use that as a clue that the management app must
      implement recovery protocol, with both source and destination files
      still being in sync and with 'query-block' still being an option as
      part of that recovery.  My testing shows that the pause window will
      typically be only a fraction of a second.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockPivot): Pause around
      drive-reopen.
      (qemuDomainBlockJobImpl): Update caller.
      400ac797
    • E
      blockjob: support pivot operation on cancel · eaba79d2
      Eric Blake 提交于
      This is the bare minimum to end a copy job (of course, until a
      later patch adds the ability to start a copy job, this patch
      doesn't do much in isolation; I've just split the patches to
      ease the review).
      
      This patch intentionally avoids SELinux, lock manager, and audit
      actions.  Also, if libvirtd restarts at the exact moment that a
      'block-job-complete' is in flight, the proposed proper way to
      detect the outcome of that would be with a persistent bitmap and
      some additional query commands when libvirtd restarts.  This
      patch is enough to test the common case of success when used
      correctly, while saving the subtleties of proper cleanup for
      worst-case errors for later.
      
      When a mirror job is started, cancelling the job safely reverts back
      to the source disk, regardless of whether the destination is in
      phase 1 (streaming, in which case the destination is worthless) or
      phase 2 (mirroring, in which case the destination is synced up to
      the source at the time of the cancel).  Our existing code does just
      fine in either phase, other than some bookkeeping cleanup; this
      implements live block copy.
      
      Ideas for future enhancements via new flags:
      
      Depending on when persistent bitmap support is added, it may be
      worth adding a VIR_DOMAIN_REBASE_COPY_ATOMIC flag that fails up
      front if we detect an older qemu with risky pivot operation.
      
      Interesting side note: while snapshot-create --disk-only creates a
      copy of the disk at a point in time by moving the domain on to a
      new file (the copy is the file now in the just-extended backing
      chain), blockjob --abort of a copy job creates a copy of the disk
      while keeping the domain on the original file.  There may be
      potential improvements to the snapshot code to exploit block copy
      over multiple disks all at one point in time.  And, if
      'block-job-cancel' were made part of 'transaction', you could
      copy multiple disks at the same point in time without pausing
      the domain.  This also implies we may want to add a --quiesce flag
      to virDomainBlockJobAbort, so that when breaking a mirror (whether
      by cancel or pivot), the side of the mirror that we are abandoning
      is at least in a stable state with regards to guest I/O.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockJobAbort): Accept new flag.
      (qemuDomainBlockPivot): New helper function.
      (qemuDomainBlockJobImpl): Implement it.
      eaba79d2
    • E
      blockjob: return appropriate event and info · edecd45c
      Eric Blake 提交于
      Handle the new type of block copy event and info.  Of course,
      this patch does nothing until a later patch actually allows the
      creation/abort of a block copy job.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_JOB_READY): New
      block job status.
      * src/libvirt.c (virDomainBlockRebase): Document the event.
      * src/qemu/qemu_monitor_json.c (eventHandlers): New event.
      (qemuMonitorJSONHandleBlockJobReady): New function.
      (qemuMonitorJSONGetBlockJobInfoOne): Translate new job type.
      (qemuMonitorJSONHandleBlockJobImpl): Handle new event and job type.
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Recognize
      the event to minimize snooping.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Snoop a successful
      info query to save effort on a pivot request.
      edecd45c
    • E
      blockjob: react to active block copy · b3822ed0
      Eric Blake 提交于
      For now, disk migration via block copy job is not implemented in
      libvirt.  But when we do implement it, we have to deal with the
      fact that qemu does not yet provide an easy way to re-start a qemu
      process with mirroring still intact.  Paolo has proposed an idea
      for a persistent dirty bitmap that might make this possible, but
      until that design is complete, it's hard to say what changes
      libvirt would need.  Even something like 'virDomainSave' becomes
      hairy, if you realize the implications that 'virDomainRestore'
      would be stuck with recreating the same mirror layout.
      
      But if we step back and look at the bigger picture, we realize that
      the initial client of live storage migration via disk mirroring is
      oVirt, which always uses transient domains, and that if a transient
      domain is destroyed while a mirror exists, oVirt can easily restart
      the storage migration by creating a new domain that visits just the
      source storage, with no loss in data.
      
      We can make life a lot easier by being cowards for now, forbidding
      certain operations on a domain.  This patch guarantees that we
      never get in a state where we would have to restart a domain with
      a mirroring block copy, by preventing saves, snapshots, migration,
      hot unplug of a disk in use, and conversion to a persistent domain
      (thankfully, it is still relatively easy to 'virsh undefine' a
      running domain to temporarily make it transient, run tests on
      'virsh blockcopy', then 'virsh define' to restore the persistence).
      Later, if the qemu design is enhanced, we can relax our code.
      
      The change to qemudDomainDefine looks a bit odd for undoing an
      assignment, rather than probing up front to avoid the assignment,
      but this is because of how virDomainAssignDef combines both a
      lookup and assignment into a single function call.
      
      * src/conf/domain_conf.h (virDomainHasDiskMirror): New prototype.
      * src/conf/domain_conf.c (virDomainHasDiskMirror): New function.
      * src/libvirt_private.syms (domain_conf.h): Export it.
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal)
      (qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
      (qemuDomainBlockJobImpl, qemudDomainDefine): Prevent dangerous
      actions while block copy is already in action.
      * src/qemu/qemu_hotplug.c (qemuDomainDetachDiskDevice): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationIsAllowed): Likewise.
      b3822ed0
    • L
      qemu: fix attach/detach of netdevs with matching mac addrs · def31e4c
      Laine Stump 提交于
      This resolves:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=862515
      
      which describes inconsistencies in dealing with duplicate mac
      addresses on network devices in a domain.
      
      (at any rate, it resolves *almost* everything, and prints out an
      informative error message for the one problem that isn't solved, but
      has a workaround.)
      
      A synopsis of the problems:
      
      1) you can't do a persistent attach-interface of a device with a mac
      address that matches an existing device.
      
      2) you *can* do a live attach-interface of such a device.
      
      3) you *can* directly edit a domain and put in two devices with
      matching mac addresses.
      
      4) When running virsh detach-device (live or config), only MAC address
      is checked when matching the device to remove, so the first device
      with the desired mac address will be removed. This isn't always the
      one that's wanted.
      
      5) when running virsh detach-interface (live or config), the only two
      items that can be specified to match against are mac address and model
      type (virtio, etc) - if multiple netdevs match both of those
      attributes, it again just finds the first one added and assumes that
      is the only match.
      
      Since it is completely valid to have multiple network devices with the
      same MAC address (although it can cause problems in many cases, there
      *are* valid use cases), what is needed is:
      
      1) remove the restriction that prohibits doing a persistent add of a
      netdev with a duplicate mac address.
      
      2) enhance the backend of virDomainDetachDeviceFlags to check for
      something that *is* guaranteed unique (but still work with just mac
      address, as long as it yields only a single results.
      
      This patch does three things:
      
      1) removes the check for duplicate mac address during a persistent
      netdev attach.
      
      2) unifies the searching for both live and config detach of netdevices
      in the subordinate functions of qemuDomainModifyDeviceFlags() to use the
      new function virDomainNetFindIdx (which matches mac address and PCI
      address if available, checking for duplicates if only mac address was
      specified). This function returns -2 if multiple matches are found,
      allowing the callers to print out an appropriate message.
      
      Steps 1 & 2 are enough to fully fix the problem when using virsh
      attach-device and detach-device (which require an XML description of
      the device rather than a bunch of commandline args)
      
      3) modifies the virsh detach-interface command to check for multiple
      matches of mac address and show an error message suggesting use of the
      detach-device command in cases where there are multiple matching mac
      addresses.
      
      Later we should decide how we want to input a PCI address on the virsh
      commandline, and enhance detach-interface to take a --address option,
      eliminating the need to use detach-device
      
      * src/conf/domain_conf.c
      * src/conf/domain_conf.h
      * src/libvirt_private.syms
        * added new virDomainNetFindIdx function
        * removed now unused virDomainNetIndexByMac and
          virDomainNetRemoveByMac
      
      * src/qemu/qemu_driver.c
        * remove check for duplicate max from qemuDomainAttachDeviceConfig
        * use virDomainNetFindIdx/virDomainNetRemove instead
          of virDomainNetRemoveByMac in qemuDomainDetachDeviceConfig
        * use virDomainNetFindIdx instead of virDomainIndexByMac
          in qemuDomainUpdateDeviceConfig
      
      * src/qemu/qemu_hotplug.c
        * use virDomainNetFindIdx instead of a homespun loop in
          qemuDomainDetachNetDevice.
      
      * tools/virsh-domain.c: modified detach-interface command as described
          above
      def31e4c
    • E
      cpustat: fix regression when cpus are offline · 4fbf322f
      Eric Blake 提交于
      It turns out that the cpuacct results properly account for offline
      cpus, and always returns results for every possible cpu, not just
      the online ones.  So there is no need to check the map of online
      cpus in the first place, merely only a need to know the maximum
      possible cpu.  Meanwhile, virNodeGetCPUBitmap had a subtle change
      from returning the maximum id to instead returning the width of
      the bitmap (one larger than the maximum id) in commit 2f4c5338,
      which made this code encounter some off-by-one logic leading to
      bad error messages when a cpu was offline:
      
      $ virsh cpu-stats dom
      error: Failed to virDomainGetCPUStats()
      
      error: An error occurred, but the cause is unknown
      
      Cleaning this up unraveled a chain of other unused variables.
      
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Drop
      pointless check for cpumap changes, and use correct number of
      cpus.  Simplify signature.
      (qemuDomainGetCPUStats): Adjust caller.
      * src/nodeinfo.h (nodeGetCPUCount): New prototype.
      (nodeGetCPUBitmap): Drop unused parameter.
      * src/nodeinfo.c (nodeGetCPUBitmap): Likewise.
      (nodeGetCPUMap): Adjust caller.
      (nodeGetCPUCount): New function.
      * src/libvirt_private.syms (nodeinfo.h): Export it.
      4fbf322f
  16. 26 10月, 2012 2 次提交
    • V
      virNodeGetCPUMap: Implement driver support · e3ba6703
      Viktor Mihajlovski 提交于
      Driver support added for:
      - test: pretending 8 host CPUS, 3 being online
      - qemu, lxc, openvz, uml: using nodeGetCPUMap
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      e3ba6703
    • E
      nodeinfo: improve probing node cpu bitmap · 2f4c5338
      Eric Blake 提交于
      Callers should not need to know what the name of the file to
      be read in the Linux-specific version of nodeGetCPUmap;
      furthermore, qemu cares about online cpus, not present cpus,
      when determining which cpus to skip.
      
      While at it, I fixed the fact that we were computing the maximum
      online cpu id by doing a slow iteration, when what we really want
      to know is the max available cpu.
      
      * src/nodeinfo.h (nodeGetCPUmap): Rename...
      (nodeGetCPUBitmap): ...and simplify signature.
      * src/nodeinfo.c (linuxParseCPUmax): New function.
      (linuxParseCPUmap): Simplify and alter signature.
      (nodeGetCPUBitmap): Change implementation.
      * src/libvirt_private.syms (nodeinfo.h): Reflect rename.
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Update
      caller.
      2f4c5338
  17. 24 10月, 2012 1 次提交
  18. 23 10月, 2012 1 次提交
    • E
      snapshot: sanity check when reusing file for snapshot · 33eaebe4
      Eric Blake 提交于
      The snapshot code when reusing an existing file had hard-to-read
      logic, as well as a missing sanity check: REUSE_EXT should require
      the destination to already be present.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare): Require
      destination on REUSE_EXT, rename variable for legibility.
      33eaebe4
  19. 22 10月, 2012 2 次提交
    • E
      storage: let format probing work on root-squash NFS · d9d77bfa
      Eric Blake 提交于
      Yet another instance of where using plain open() mishandles files
      that live on root-squash NFS, and where improving the API can
      improve the chance of a successful probe.
      
      * src/util/storage_file.h (virStorageFileProbeFormat): Alter
      signature.
      * src/util/storage_file.c (virStorageFileProbeFormat): Use better
      method for opening file.
      * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Update caller.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.
      d9d77bfa
    • J
      migrate: v2: use VIR_DOMAIN_XML_MIGRATABLE when available · b6ab7a06
      Ján Tomko 提交于
      In v2 migration protocol, XML is obtained by calling domainGetXMLDesc.
      This includes the default USB controller in XML, which breaks migration
      to older libvirt (before 0.9.2).
      
      Commit 409b5f54
          qemu: Emit compatible XML when migrating a domain
      only fixed this for v3 migration.
      
      This patch uses the new VIR_DOMAIN_XML_MIGRATABLE flag (detected by
      VIR_DRV_FEATURE_XML_MIGRATABLE) to obtain XML without the default controller,
      enabling backward v2 migration.
      b6ab7a06
  20. 20 10月, 2012 3 次提交
    • E
      blockjob: avoid segv on early error · a172dfbe
      Eric Blake 提交于
      Gcc with optimization warns:
      ../../src/qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
      ../../src/qemu/qemu_driver.c:12813:46: error: 'disk' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      ../../src/qemu/qemu_driver.c:12698:25: note: 'disk' was declared here
      cc1: all warnings being treated as errors
      
      so obviously I had only been testing with optimization off.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Guard cleanup.
      a172dfbe
    • E
      blockjob: properly label disks for qemu block-commit · 2e43cb8e
      Eric Blake 提交于
      I finally have all the pieces in place to perform a block-commit with
      SELinux enforcing.  There's still missing cleanup work when the commit
      completes, but doing that requires tracking both the backing chain and
      the base and top files within that chain in domain XML across libvirtd
      restarts.  Furthermore, from a security standpoint, once you have
      granted access, you must assume any damage that can be done will be
      done; later revoking access is nice to minimize the window of damage,
      but less important as it does not affect the fact that damage can be
      done in the first place.  Therefore, deferring the revoke efforts until
      we have better XML tracking of what chain operations are in effect,
      including across a libvirtd restart, is reasonable.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Label disks as
      needed.
      (qemuDomainPrepareDiskChainElement): Cast away const.
      2e43cb8e
    • E
      blockjob: refactor qemu disk chain permission grants · 35a2f5bc
      Eric Blake 提交于
      Previously, snapshot code did its own permission granting (lock
      manager, cgroup device controller, and security manager labeling)
      inline.  But now that we are adding block-commit and block-copy
      which also have to change permissions, it's better to reuse
      common code for the task.  While snapshot should fall back to
      no access if read-write access failed, block-commit will want to
      fall back to read-only access.  The common code doesn't know
      whether failure to grant read-write access should revert to no
      access (snapshot, block-copy) or read-only access (block-commit).
      This code can also be used to revoke access to unused files after
      block-pull.
      
      It might be nice to clean things up in a future patch by adding
      new functions to the lock manager, cgroup manager, and security
      manager that takes a single file name and applies context of a
      disk to that file, rather than the current semantics of applying
      context to the entire chain already associated to a disk.  That
      way, we could avoid the games this patch plays of temporarily
      swapping out the disk->src and related fields of the disk.  But
      that would involve more code changes, so this patch really is
      the smallest hack for doing the necessary work; besides, this
      patch is more or less code motion (the hack was already employed
      by the snapshot creation code, we are just making it reusable).
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotUndoSingleDiskActive): Refactor labeling hacks...
      (qemuDomainPrepareDiskChainElement): ...into new function.
      35a2f5bc