1 /* 2 * qemu_saveimage.h: Infrastructure for saving qemu state to a file 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library. If not, see 16 * <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "virconftypes.h" 22 #include "datatypes.h" 23 24 #include "qemu_conf.h" 25 #include "qemu_domainjob.h" 26 #include "qemu_domain.h" 27 28 /* It would be nice to replace 'Qemud' with 'Qemu' but 29 * this magic string is ABI, so it can't be changed 30 */ 31 #define QEMU_SAVE_MAGIC "LibvirtQemudSave" 32 #define QEMU_SAVE_PARTIAL "LibvirtQemudPart" 33 #define QEMU_SAVE_VERSION 2 34 35 G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) == sizeof(QEMU_SAVE_PARTIAL)); 36 37 typedef struct _virQEMUSaveHeader virQEMUSaveHeader; 38 struct _virQEMUSaveHeader { 39 char magic[sizeof(QEMU_SAVE_MAGIC)-1]; 40 uint32_t version; 41 uint32_t data_len; 42 uint32_t was_running; 43 uint32_t compressed; 44 uint32_t cookieOffset; 45 uint32_t unused[14]; 46 }; 47 48 49 typedef struct _virQEMUSaveData virQEMUSaveData; 50 struct _virQEMUSaveData { 51 virQEMUSaveHeader header; 52 char *xml; 53 char *cookie; 54 }; 55 56 57 virDomainDef * 58 qemuSaveImageUpdateDef(virQEMUDriver *driver, 59 virDomainDef *def, 60 const char *newxml); 61 62 int 63 qemuSaveImageStartVM(virConnectPtr conn, 64 virQEMUDriver *driver, 65 virDomainObj *vm, 66 int *fd, 67 virQEMUSaveData *data, 68 const char *path, 69 bool start_paused, 70 qemuDomainAsyncJob asyncJob) 71 ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6); 72 73 int 74 qemuSaveImageOpen(virQEMUDriver *driver, 75 virQEMUCaps *qemuCaps, 76 const char *path, 77 virDomainDef **ret_def, 78 virQEMUSaveData **ret_data, 79 bool bypass_cache, 80 virFileWrapperFd **wrapperFd, 81 bool open_write, 82 bool unlink_corrupt) 83 ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); 84 85 int 86 qemuSaveImageGetCompressionProgram(const char *imageFormat, 87 virCommand **compressor, 88 const char *styleFormat, 89 bool use_raw_on_fail) 90 ATTRIBUTE_NONNULL(2); 91 92 int 93 qemuSaveImageCreate(virQEMUDriver *driver, 94 virDomainObj *vm, 95 const char *path, 96 virQEMUSaveData *data, 97 virCommand *compressor, 98 unsigned int flags, 99 qemuDomainAsyncJob asyncJob); 100 101 int 102 virQEMUSaveDataWrite(virQEMUSaveData *data, 103 int fd, 104 const char *path); 105 106 virQEMUSaveData * 107 virQEMUSaveDataNew(char *domXML, 108 qemuDomainSaveCookie *cookieObj, 109 bool running, 110 int compressed, 111 virDomainXMLOption *xmlopt); 112 113 void 114 virQEMUSaveDataFree(virQEMUSaveData *data); 115