1. 20 9月, 2011 1 次提交
  2. 17 9月, 2011 3 次提交
    • E
      snapshot: allow disk snapshots of qcow2 disks · 43c2641c
      Eric Blake 提交于
      For all types of disks other than qcow2, we were requesting that
      SELinux labeling visit the new file as if it were qcow2, which
      means labeling would try to find the backing files of an empty file.
      And for a pre-existing qcow2 disk, we were passing NULL, which meant
      that labelling tried to probe the file type (and if probing is
      disabled, per the default qemu.conf, this made snapshots fail).
      What we really want is to make SELinux labeling visit the new
      file as raw; it will later be converted to qcow2 if qemu successfully
      made the snapshot.
      
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive): Force SELinux labeling
      to avoid probe of new file.
      43c2641c
    • E
      snapshot: affect persistent xml after disk snapshot · 2895905a
      Eric Blake 提交于
      For external snapshots to be useful on persistent domains, we must
      alter the persistent definition alongside the running definition.
      Thanks to the possibility of disk hotplug as well as of edits that
      only affect the persistent xml, we can't assume that vm->def and
      vm->newDef have the same disk at the same index, so we can only
      update the persistent copy if the device destination matches up.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive)
      (qemuDomainSnapshotCreateSingleDiskActive): Also affect newDef, if
      present.
      2895905a
    • A
      qemu: add return value check · 14c22b3b
      Alex Jia 提交于
      * src/qemu/qemu_command.c: missing return value check.
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      14c22b3b
  3. 16 9月, 2011 6 次提交
    • J
      qemu: Introduce shutdown reason for paused state · d2d67763
      Jiri Denemark 提交于
      Qemu sends STOP event as part of the shutdown process. Detect such STOP
      event and consider shutdown to be reason of emitting such event. That's
      the best we can do until qemu provides us the reason directly in STOP
      event. This allows us to report shutdown reason for paused state so that
      apps can detect domains that failed to finish the shutdown process
      (e.g., because qemu is buggy and doesn't exit on SIGTERM or it is
      blocked in flushing disk buffers).
      d2d67763
    • J
      qemu: Prevent disk corruption on domain shutdown · 96fc4784
      Jiri Denemark 提交于
      Ever since we introduced fake reboot, we call qemuProcessKill as a
      reaction to SHUTDOWN event. Unfortunately, qemu doesn't guarantee it
      flushed all internal buffers before sending SHUTDOWN, in which case
      killing the process forcibly may result in (virtual) disk corruption.
      
      By sending just SIGTERM without SIGKILL we give qemu time to to flush
      all buffers and exit. Once qemu exits, we will see an EOF on monitor
      connection and tear down the domain. In case qemu ignores SIGTERM or
      just hangs there, the process stays running but that's not any different
      from a possible hang anytime during the shutdown process so I think it's
      just fine.
      
      Also qemu (since 0.14 until it's fixed) has a bug in SIGTERM processing
      which causes it not to exit but instead send new SHUTDOWN event and keep
      waiting. I think the best we can do is to ignore duplicate SHUTDOWN
      events to avoid a SHUTDOWN-SIGTERM loop and leave the domain in paused
      state.
      96fc4784
    • J
      qemu: Properly detect crash of a rebooted domain · c2e9fab2
      Jiri Denemark 提交于
      When a domain is rebooted using libvirt API, we use fake reboot
      consisting of shutting down and resetting the domain. Thus we see a
      SHUTDOWN event and set gotShutdown flag. But we never reset it back and
      if the domain crashes after it was rebooted this way, we consider it was
      a normal shutdown and not a crash.
      c2e9fab2
    • J
      qemu: Fix shutoff reason when domain crashes · 3acb664c
      Jiri Denemark 提交于
      Commit 4454a9ef changed shutoff reason
      from VIR_DOMAIN_SHUTOFF_CRASHED to VIR_DOMAIN_SHUTOFF_FAILED in case we
      see an unexpected EOF on monitor connection. But FAILED reason is
      dedicated for domains that fail to start. CRASHED reason is the right
      one to use in this situation.
      3acb664c
    • S
      Fix buzzilla 738778 · 3f2cb3ab
      Stefan Berger 提交于
      This patch fixes the bug shown in bugzilla 738778. It's not an nwfilter problem but a connection sharing / closure issue.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=738778
      
      Depending on the speed / #CPUs of the machine you are using you may not see this bug all the time.
      3f2cb3ab
    • P
      Avoid using "devname" as an identifier. · 79cf07af
      Peter Krempa 提交于
      /usr/lib/stdlib.h in Mac OS X and probably also in BSD's
      exports this symbol :(
      79cf07af
  4. 15 9月, 2011 6 次提交
  5. 14 9月, 2011 1 次提交
    • P
      xml: Clean up rest of virtual XML document names for XML strings · b998f1f7
      Peter Krempa 提交于
      Commit 498d7833 cleans up some of virtual file names for parsing strings
      in memory. This patch cleans up (hopefuly) the rest forgotten by the
      first patch.
      
      This patch also changes all of the previously modified "filenames" to
      valid URI's replacing spaces for underscores.
      
      Changes to v1:
      - Replace all spaces for underscores, so that the strings form valid
        URI's
      - Replace spaces in places changed by commit 498d7833
      b998f1f7
  6. 13 9月, 2011 1 次提交
    • G
      snapshot: fix double free of qemuImgBinary · 011eeb41
      Guannan Ren 提交于
      Regression introduced in commit 3881a470, due to an improper rebase
      of a cleanup written beforehand but only applied after a rebased of
      a refactoring that created a new function in commit 25fb3ef1.
      
      Also avoids passing NULL to printf %s.
      
      * src/qemu/qemu_driver.c: In qemuDomainSnapshotForEachQcow2()
      it free up the memory of qemu_driver->qemuImgBinary in the
      cleanup tag which leads to the garbage value of qemuImgBinary
      in qemu_driver struct and libvirtd crash when running
      "virsh snapshot-create" command a second time.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      011eeb41
  7. 08 9月, 2011 1 次提交
  8. 06 9月, 2011 7 次提交
    • P
      link-state: qemu: Add net intf modification to virUpdateDeviceFlags · e0a07bb1
      Peter Krempa 提交于
      This patch enables modifying network device configuration using the
      virUpdateDeviceFlags API method. Matching of devices is accomplished
      using MAC addresses.
      
      While updating live configuration of a running domain, the user is
      allowed only to change link state of the interface. Additional
      modifications may be added later. For now the code checks for
      unsupported changes and thereafter changes the link state, if
      applicable.
      
      When updating persistent configuration of guest's network interface the
      whole configuration (except for the MAC address) may be modified and
      is stored for the next startup.
      
      * src/qemu/qemu_driver.c   - Add dispatching of virUpdateDevice for
                                   network devices update (live/config)
      * src/qemu/qemu_hotplug.c  - add setting of initial link state on live
                                   device addition
                                 - add function to change network device
                                   configuration. By now it supports only
                                   changing of link state
      * src/qemu/qemu_hotplug.h  - Headers to above functions
      * src/qemu/qemu_process.c  - set link states before virtual machine
                                   start. Qemu does not support setting of
                                   this on the command line.
      e0a07bb1
    • P
      link-state: qemu: Add monitor handling for link state modification · 8277c151
      Peter Krempa 提交于
      This patch adds handlers for modification of guest's interface
      link state. Both HMP and QMP commands are supported, but as the
      link state functionality is from the beginning supported in QMP
      the HMP code will probably never be used.
      8277c151
    • O
      latency: Implemente internal API for qemu driver · ee0d8c3b
      Osier Yang 提交于
      ee0d8c3b
    • O
      latency: Update monitor functions for new latency fields · 2f58ba89
      Osier Yang 提交于
      The mainly changes are:
      
      1) Update qemuMonitorGetBlockStatsInfo and it's children (Text/JSON)
         functions to return the value of new latency fields.
      2) Add new function qemuMonitorGetBlockStatsParamsNumber, which is
         to count how many parameters the underlying QEMU supports.
      3) Update virDomainBlockStats in src/qemu/qemu_driver.c to be
         compatible with the changes by 1).
      2f58ba89
    • M
      qemu: Deal with stucked qemu on daemon startup · d38897a5
      Michal Privoznik 提交于
      If libvirt daemon gets restarted and there is (at least) one
      unresponsive qemu, the startup procedure hangs up. This patch creates
      one thread per vm in which we try to reconnect to monitor. Therefore,
      blocking in one thread will not affect other APIs.
      d38897a5
    • M
      qemu: Introduce job queue size limit · 3005cacb
      Michal Privoznik 提交于
      This patch creates an optional BeginJob queue size limit. When
      active, all other attempts above level will fail. To set this
      feature assign desired value to max_queued variable in qemu.conf.
      Setting it to 0 turns it off.
      3005cacb
    • M
      daemon: Create priority workers pool · 597fe3ce
      Michal Privoznik 提交于
      This patch annotates APIs with low or high priority.
      In low set MUST be all APIs which might eventually access monitor
      (and thus block indefinitely). Other APIs may be marked as high
      priority. However, some must be (e.g. domainDestroy).
      
      For high priority calls (HPC), there are some high priority workers
      (HPW) created in the pool. HPW can execute only HPC, although normal
      worker can process any call regardless priority. Therefore, only those
      APIs which are guaranteed to end in reasonable small amount of time
      can be marked as HPC.
      
      The size of this HPC pool is static, because HPC are expected to end
      quickly, therefore jobs assigned to this pool will be served quickly.
      It can be configured in libvirtd.conf via prio_workers variable.
      Default is set to 5.
      
      To mark API with low or high priority, append priority:{low|high} to
      it's comment in src/remote/remote_protocol.x. This is similar to
      autogen|skipgen. If not marked, the generator assumes low as default.
      597fe3ce
  9. 05 9月, 2011 12 次提交
    • E
      snapshot: use SELinux and lock manager with external snapshots · 63379890
      Eric Blake 提交于
      With this, it is now possible to create external snapshots even
      when SELinux is enforcing, and to protect the new file with a
      lock manager.
      
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive): Create and register
      new file with proper permissions and locks.
      (qemuDomainSnapshotCreateDiskActive): Update caller.
      63379890
    • E
      snapshot: wire up live qemu disk snapshots · 9c21b441
      Eric Blake 提交于
      Lots of earlier patches led up to this point - the qemu snapshot_blkdev
      monitor command can now be controlled by libvirt!  Well, insofar as
      SELinux doesn't prevent qemu from open(O_CREAT) on the files.  There's
      still some followup work before things work with SELinux enforcing,
      but this patch is big enough to post now.
      
      There's still room for other improvements, too (for example, taking a
      disk snapshot of an inactive domain, by using qemu-img for both internal
      and external snapshots; wiring up delete and revert control, including
      additional flags from my RFC; supporting active QED disk snapshots;
      supporting per-storage-volume snapshots such as LVM or btrfs snapshots;
      etc.).  But this patch is the one that proves the new XML works!
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Wire in
      active disk snapshots.
      (qemuDomainSnapshotDiskPrepare)
      (qemuDomainSnapshotCreateDiskActive)
      (qemuDomainSnapshotCreateSingleDiskActive): New functions.
      9c21b441
    • E
      snapshot: wire up new qemu monitor command · e702b5ba
      Eric Blake 提交于
      No one uses this yet, but it will be important once
      virDomainSnapshotCreateXML learns a VIR_DOMAIN_SNAPSHOT_DISK_ONLY
      flag, and the xml allows passing in the new file names.
      
      * src/qemu/qemu_monitor.h (qemuMonitorDiskSnapshot): New prototype.
      * src/qemu/qemu_monitor_text.h (qemuMonitorTextDiskSnapshot):
      Likewise.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot):
      Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorDiskSnapshot): New
      function.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot):
      Likewise.
      e702b5ba
    • E
      snapshot: make it possible to audit external snapshot · c111517a
      Eric Blake 提交于
      Snapshots alter the set of disk image files opened by qemu, so
      they must be audited.  But they don't involve a full disk definition
      structure, just the new filename.  Make the next patch easier by
      refactoring the audit routines to just operate on file name.
      
      * src/conf/domain_audit.h (virDomainAuditDisk): Update prototype.
      * src/conf/domain_audit.c (virDomainAuditDisk): Act on strings,
      not definition structures.
      (virDomainAuditStart): Update caller.
      * src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia)
      (qemuDomainAttachPciDiskDevice, qemuDomainAttachSCSIDisk)
      (qemuDomainAttachUsbMassstorageDevice)
      (qemuDomainDetachPciDiskDevice, qemuDomainDetachDiskDevice):
      Likewise.
      c111517a
    • E
      snapshot: reject unimplemented disk snapshot features · 7807e05d
      Eric Blake 提交于
      My RFC for snapshot support [1] proposes several rules for when it is
      safe to delete or revert to an external snapshot, predicated on
      the existence of new API flags.  These will be incrementally added
      in future patches, but until then, blindly mishandling a disk
      snapshot risks corrupting internal state, so it is better to
      outright reject the attempts until the other pieces are in place,
      thus incrementally relaxing the restrictions added in this patch.
      
      [1] https://www.redhat.com/archives/libvir-list/2011-August/msg00361.html
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCountExternal): New
      function.
      (qemuDomainUndefineFlags, qemuDomainSnapshotDelete): Use it to add
      safety valve.
      (qemuDomainRevertToSnapshot, qemuDomainSnapshotCreateXML): Add safety
      valve.
      7807e05d
    • E
      snapshot: add flag for requesting disk snapshot · e03a62b4
      Eric Blake 提交于
      Prior to this patch, <domainsnapshot>/<disks> was ignored.  This
      changes it to be an error unless an explicit disk snapshot is
      requested (a future patch may relax things if it turns out to
      be useful to have a <disks> specification alongside a system
      checkpoint).
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY): New flag.
      * src/libvirt.c (virDomainSnapshotCreateXML): Document it.
      * src/esx/esx_driver.c (esxDomainSnapshotCreateXML): Disk
      snapshots not supported yet.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Likewise.
      e03a62b4
    • E
      snapshot: also support disks by path · 89b6284f
      Eric Blake 提交于
      I got confused when 'virsh domblkinfo dom disk' required the
      path to a disk (which can be ambiguous, since a single file
      can back multiple disks), rather than the unambiguous target
      device name that I was using in disk snapshots.  So, in true
      developer fashion, I went for the best of both worlds - all
      interfaces that operate on a disk (aka block) now accept
      either the target name or the unambiguous path to the backing
      file used by the disk.
      
      * src/conf/domain_conf.h (virDomainDiskIndexByName): Add
      parameter.
      (virDomainDiskPathByName): New prototype.
      * src/libvirt_private.syms (domain_conf.h): Export it.
      * src/conf/domain_conf.c (virDomainDiskIndexByName): Also allow
      searching by path, and decide whether ambiguity is okay.
      (virDomainDiskPathByName): New function.
      (virDomainDiskRemoveByName, virDomainSnapshotAlignDisks): Update
      callers.
      * src/qemu/qemu_driver.c (qemudDomainBlockPeek)
      (qemuDomainAttachDeviceConfig, qemuDomainUpdateDeviceConfig)
      (qemuDomainGetBlockInfo, qemuDiskPathToAlias): Likewise.
      * src/qemu/qemu_process.c (qemuProcessFindDomainDiskByPath):
      Likewise.
      * src/libxl/libxl_driver.c (libxlDomainAttachDeviceDiskLive)
      (libxlDomainDetachDeviceDiskLive, libxlDomainAttachDeviceConfig)
      (libxlDomainUpdateDeviceConfig): Likewise.
      * src/uml/uml_driver.c (umlDomainBlockPeek): Likewise.
      * src/xen/xend_internal.c (xenDaemonDomainBlockPeek): Likewise.
      * docs/formatsnapshot.html.in: Update documentation.
      * tools/virsh.pod (domblkstat, domblkinfo): Likewise.
      * docs/schemas/domaincommon.rng (diskTarget): Tighten pattern on
      disk targets.
      * docs/schemas/domainsnapshot.rng (disksnapshot): Update to match.
      * tests/domainsnapshotxml2xmlin/disk_snapshot.xml: Update test.
      89b6284f
    • E
      snapshot: allow halting after snapshot · 6f66423e
      Eric Blake 提交于
      Since a snapshot is fully recoverable, it is useful to have a
      snapshot as a means of hibernating a guest, then reverting to
      the snapshot to wake the guest up.  This mode of usage is
      similar to 'virsh save/virsh restore', except that virsh
      save uses an external file while virsh snapshot keeps the
      vm state internal to a qcow2 file.  However, it only works on
      persistent domains.
      
      In the usage pattern of snapshot/revert for hibernating a guest,
      there is no need to keep the guest running between the two points
      in time, especially since that would generate runtime state that
      would just be discarded.  Add a flag to make it possible to
      stop the domain after the snapshot has completed.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_SNAPSHOT_CREATE_HALT):
      New flag.
      * src/libvirt.c (virDomainSnapshotCreateXML): Document it.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML)
      (qemuDomainSnapshotCreateActive): Implement it.
      6f66423e
    • E
      snapshot: introduce new deletion flag · 3d77d0a6
      Eric Blake 提交于
      Reverting to a state prior to an external snapshot risks
      corrupting any other branches in the snapshot hierarchy that
      were using the snapshot as a read-only backing file.  So
      disk snapshot code will default to preventing reverting to
      a snapshot that has any children, meaning that deleting just
      the children of a snapshot becomes a useful operation in
      preparing that snapshot for being a future reversion target.
      The code for the new flag is simple - it's one less deletion,
      plus a tweak to keep the current snapshot correct.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY): New flag.
      * src/libvirt.c (virDomainSnapshotDelete): Document it, and
      enforce mutual exclusion.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Implement
      it.
      3d77d0a6
    • E
      snapshot: reject transient disks where code is not ready · e91d27ee
      Eric Blake 提交于
      The previous patch introduced new config, but if a hypervisor does
      not support that new config, someone can write XML that does not
      behave as documented.  This prevents some of those cases by
      explicitly rejecting transient disks for several hypervisors.
      
      Disk snapshots will require a new flag to actually affect a snapshot
      creation, so there's not much to reject there.
      
      * src/qemu/qemu_command.c (qemuBuildDriveStr): Reject transient
      disks for now.
      * src/libxl/libxl_conf.c (libxlMakeDisk): Likewise.
      * src/xenxs/xen_sxpr.c (xenFormatSxprDisk): Likewise.
      * src/xenxs/xen_xm.c (xenFormatXMDisk): Likewise.
      e91d27ee
    • M
      Default USB device is on slot 1 function 2 · 360aaafc
      Marc-André Lureau 提交于
      Fix qemuAssignDevicePCISlots() and the associated regression tests
      360aaafc
    • M
      PIIX3 USB controller is on function 2 · 07901bf2
      Marc-André Lureau 提交于
      Current code reserves slot 1 function 2 even if there is a user
      defined PIIX3 USB controller there.
      07901bf2
  10. 03 9月, 2011 2 次提交
    • E
      snapshot: store qemu domain details in xml · 973fcd8f
      Eric Blake 提交于
      When reverting to a snapshot, the inactive domain configuration
      has to be rolled back to what it was at the time of the snapshot.
      Additionally, if the VM is active and the snapshot was active,
      this now adds a failure if the two configurations are ABI
      incompatible, rather than risking qemu confusion.
      
      A future patch will add a VIR_DOMAIN_SNAPSHOT_FORCE flag, which
      will be required for two risky code paths - reverting to an
      older snapshot that lacked full domain information, and reverting
      from running to a live snapshot that requires starting a new qemu
      process.  Any reverting that stops a running vm is also a form
      of data loss (discarding the current running state to go back in
      time), but as that is what reversion usually implies, it is
      probably not worth requiring a force flag.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Copy out
      domain.
      (qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot): Perform
      ABI compatibility checks.
      973fcd8f
    • E
      snapshot: allow full domain xml in snapshot · f609cb85
      Eric Blake 提交于
      Just like VM saved state images (virsh save), snapshots MUST
      track the inactive domain xml to detect any ABI incompatibilities.
      
      The indentation is not perfect, but functionality comes before form.
      
      Later patches will actually supply a full domain; for now, this
      wires up the storage to support one, but doesn't ever generate one
      in dumpxml output.
      
      Happily, libvirt.c was already rejecting use of VIR_DOMAIN_XML_SECURE
      from read-only connections, even though before this patch, there was
      no information to be secured by the use of that flag.
      
      And while we're at it, mark the libvirt snapshot metadata files
      as internal-use only.
      
      * src/libvirt.c (virDomainSnapshotGetXMLDesc): Document flag.
      * src/conf/domain_conf.h (_virDomainSnapshotDef): Add member.
      (virDomainSnapshotDefParseString, virDomainSnapshotDefFormat):
      Update signature.
      * src/conf/domain_conf.c (virDomainSnapshotDefFree): Clean up.
      (virDomainSnapshotDefParseString): Optionally parse domain.
      (virDomainSnapshotDefFormat): Output full domain.
      * src/esx/esx_driver.c (esxDomainSnapshotCreateXML)
      (esxDomainSnapshotGetXMLDesc): Update callers.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML)
      (vboxDomainSnapshotGetXMLDesc): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML)
      (qemuDomainSnapshotLoad, qemuDomainSnapshotGetXMLDesc)
      (qemuDomainSnapshotWriteMetadata): Likewise.
      * docs/formatsnapshot.html.in: Rework doc example.
      Based on a patch by Philipp Hahn.
      f609cb85