On Thu, Jan 03, 2013 at 05:45:49PM +0100, Peter Krempa wrote:
---
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/qemu/qemu_driver.c | 492 ++-----------------------------------------------
src/qemu/qemu_util.c | 486 ++++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_util.h | 111 +++++++++++
5 files changed, 611 insertions(+), 480 deletions(-)
create mode 100644 src/qemu/qemu_util.c
create mode 100644 src/qemu/qemu_util.h
+# include "qemu_domain.h"
+
+/* It would be nice to replace 'Qemud' with 'Qemu' but
+ * this magic string is ABI, so it can't be changed
+ */
+# define QEMU_SAVE_MAGIC "LibvirtQemudSave"
+# define QEMU_SAVE_PARTIAL "LibvirtQemudPart"
+# define QEMU_SAVE_VERSION 2
+
+verify(sizeof(QEMU_SAVE_MAGIC) == sizeof(QEMU_SAVE_PARTIAL));
+
+typedef struct _virQEMUSaveHeader virQEMUSaveHeader;
+typedef virQEMUSaveHeader *virQEMUSaveHeaderPtr;
+struct _virQEMUSaveHeader {
+ char magic[sizeof(QEMU_SAVE_MAGIC)-1];
+ uint32_t version;
+ uint32_t xml_len;
+ uint32_t was_running;
+ uint32_t compressed;
+ uint32_t unused[15];
+};
+
+
+typedef enum {
+ VIR_DISK_CHAIN_NO_ACCESS,
+ VIR_DISK_CHAIN_READ_ONLY,
+ VIR_DISK_CHAIN_READ_WRITE,
+} qemuDomainDiskChainMode;
+
+typedef enum {
+ QEMU_SAVE_FORMAT_RAW = 0,
+ QEMU_SAVE_FORMAT_GZIP = 1,
+ QEMU_SAVE_FORMAT_BZIP2 = 2,
+ /*
+ * Deprecated by xz and never used as part of a release
+ * QEMU_SAVE_FORMAT_LZMA
+ */
+ QEMU_SAVE_FORMAT_XZ = 3,
+ QEMU_SAVE_FORMAT_LZOP = 4,
+ /* Note: add new members only at the end.
+ These values are used in the on-disk format.
+ Do not change or re-use numbers. */
+
+ QEMU_SAVE_FORMAT_LAST
+} virQEMUSaveFormat;
+
+VIR_ENUM_DECL(qemuSaveCompression)
+
+
+virDomainObjPtr qemuDomObjFromDomainDriver(virDomainPtr domain,
+ virQEMUDriverPtr *drv);
+
+virDomainObjPtr qemuDomObjFromDomain(virDomainPtr domain);
+
+virDomainObjPtr qemuDomObjFromSnapshot(virDomainSnapshotPtr snapshot);
+
+virDomainSnapshotObjPtr qemuSnapObjFromSnapshot(virDomainObjPtr vm,
+ virDomainSnapshotPtr snapshot);
+
+virDomainSnapshotObjPtr qemuSnapObjFromName(virDomainObjPtr vm,
+ const char *name);
All these should go in qemu_domain.{c,h}
+int qemuOpenFile(virQEMUDriverPtr driver,
+ const char *path,
+ int oflags,
+ bool *needUnlink,
+ bool *bypassSecurityDriver);
qemu_conf.c
+int qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virCgroupPtr cgroup,
+ virDomainDiskDefPtr disk,
+ const char *file,
+ qemuDomainDiskChainMode mode);
qemu_domain.h
+int qemuDomainSaveMemory(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ const char *path,
+ const char *domXML,
+ int compressed,
+ bool was_running,
+ unsigned int flags,
+ enum qemuDomainAsyncJob asyncJob);
Not convinced this needs to move at all.
+const char *qemuCompressProgramName(int compress);
qemu_domain.h
In summary, I don't think we should create a qemu_util.{c,h} file - any
file named util just ends up as a garbage dumping ground for code that
should be better placed elsewhere. See also util/util.h which should be
split up.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|