[libvirt] [PATCH] Allow saving QEMU libvirt state to a pipe

Roy Keene rkeene at knightpoint.com
Fri Nov 4 20:20:44 UTC 2016


All,

     Currently the "virsh save" command opens a file to save a domain's 
XML and memory state, does the save, and then re-opens the file to 
simulate seeking to the beginning to update the header to indicate that 
the file is complete.

For pipes this is not possible, attempting to re-open the pipe will not 
connect you to the same consumer.  Seeking is also not possible on a pipe.

Attached is a patch that detects if the file being written to is not 
seekable, and if so writes the completed header initially, then writes 
the normal data, and avoids re-opening the file.

This is useful to me for saving a VM state directly to Ceph RBD images 
without having an intermediate file.

I've tested this patch successfully (against v1.3.5) for both saving and 
restoring a domain:

# *( fifo="$(mktemp -u)"; mkfifo "${fifo}" && virsh save one-0 "${fifo}" 
& cat "${fifo}" | rbd import - rbd/test1234 & wait; rm -f "${fifo}" )*

Domain one-0 saved to /tmp/tmp.HK4hChiQqB

#

# *( fifo="$(mktemp -u)"; mkfifo "${fifo}" && rbd export rbd/test1234 - 
 > "${fifo}" & virsh restore "${fifo}" & wait; rm -f "${fifo}" ) *
Exporting image: 100% complete...done.
Domain restored from /tmp/tmp.0YaUZ5Y2yT

# *virsh list*
  Id    Name                           State
----------------------------------------------------
  11    one-0                          running
#

-- 
	Roy Keene
	Knight Point Systems, LLC
	Service-Disabled Veteran-Owned Business
	1775 Wiehle Avenue Suite 101 | Reston, VA 20190
	c: 813-956-3808    f: 571-266-3106
	www.knightpoint.com
	DHS EAGLE II Prime Contractor: FC1 SDVOSB Track
	GSA Schedule 70 SDVOSB: GS-35F-0646S
	GSA MOBIS Schedule: GS-10F-0404Y
	ISO 20000 / ISO 27001

	Notice: This e-mail message, including any attachments, is for the
	sole use of the intended recipient(s) and may contain confidential
	and privileged information.  Any unauthorized review,  copy,  use,
	disclosure, or distribution is STRICTLY prohibited. If you are not
	the intended recipient,  please contact the sender by reply e-mail
	and destroy all copies of the original message.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161104/ebd041a9/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-1.3.5-savepipe.diff
Type: text/x-patch
Size: 3802 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161104/ebd041a9/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3455 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161104/ebd041a9/attachment-0001.p7s>


More information about the libvir-list mailing list