On Sun, Aug 12, 2007 at 07:11:38PM -0400, Jim Paris wrote:
The save file format consists of a header, XML for the domain,
and the raw QEMU/KVM migration data stream.
-static int qemudDomainSave(virDomainPtr dom,
- const char *path ATTRIBUTE_UNUSED) {
+#define QEMUD_SAVE_MAGIC "LibvirtQemudSave"
+struct qemud_save_header {
+ char magic[sizeof(QEMUD_SAVE_MAGIC)-1];
I suggest to add an "int version" field here to be able to extend the
format.
+ int xml_len;
+ int was_running;
and "int unused[16];"
With those 2 we should be able to cope with backward compatibility on
saved domain even if we don't know yet what may be needed. At worse it's
a few bytes lost in a very big file, at best it's a life saver.
+ memset(&header, 0, sizeof(header));
+ memcpy(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic));
#define QEMU_SAVE_VERSION 1 somewhere and then
header.version = QEMU_SAVE_VERSION;
+ header.xml_len = strlen(xml);
maybe + 1 to account for the trailing 0
+ if (write(fd, &header, sizeof(header)) != sizeof(header)) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+ "failed to write save header");
+ close(fd);
+ free(xml);
+ return -1;
+ }
I suggest to define or reuse existing safe write and read routines which
handle interruped calls with EAGAIN.
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/