mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Add privateData to virDomainDiskDef
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
3511c12244
commit
890fa6a055
@ -1275,7 +1275,7 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
|
||||
|
||||
|
||||
virDomainDiskDefPtr
|
||||
virDomainDiskDefNew(void)
|
||||
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
|
||||
{
|
||||
virDomainDiskDefPtr ret;
|
||||
|
||||
@ -1285,6 +1285,11 @@ virDomainDiskDefNew(void)
|
||||
if (VIR_ALLOC(ret->src) < 0)
|
||||
goto error;
|
||||
|
||||
if (xmlopt &&
|
||||
xmlopt->privateData.diskNew &&
|
||||
!(ret->privateData = xmlopt->privateData.diskNew()))
|
||||
goto error;
|
||||
|
||||
if (virCondInit(&ret->blockJobSyncCond) < 0) {
|
||||
virReportSystemError(errno, "%s", _("Failed to initialize condition"));
|
||||
goto error;
|
||||
@ -1293,9 +1298,7 @@ virDomainDiskDefNew(void)
|
||||
return ret;
|
||||
|
||||
error:
|
||||
virStorageSourceFree(ret->src);
|
||||
VIR_FREE(ret);
|
||||
|
||||
virDomainDiskDefFree(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1315,6 +1318,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
|
||||
VIR_FREE(def->product);
|
||||
VIR_FREE(def->domain_name);
|
||||
virDomainDeviceInfoClear(&def->info);
|
||||
virObjectUnref(def->privateData);
|
||||
virCondDestroy(&def->blockJobSyncCond);
|
||||
|
||||
VIR_FREE(def);
|
||||
@ -6121,7 +6125,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
int auth_secret_usage = -1;
|
||||
int ret = 0;
|
||||
|
||||
if (!(def = virDomainDiskDefNew()))
|
||||
if (!(def = virDomainDiskDefNew(xmlopt)))
|
||||
return NULL;
|
||||
|
||||
def->geometry.cylinders = 0;
|
||||
|
@ -683,6 +683,8 @@ typedef enum {
|
||||
struct _virDomainDiskDef {
|
||||
virStorageSourcePtr src; /* non-NULL. XXX Allow NULL for empty cdrom? */
|
||||
|
||||
virObjectPtr privateData;
|
||||
|
||||
int device; /* enum virDomainDiskDevice */
|
||||
int bus; /* enum virDomainDiskBus */
|
||||
char *dst;
|
||||
@ -2332,6 +2334,7 @@ typedef virDomainXMLOption *virDomainXMLOptionPtr;
|
||||
|
||||
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
|
||||
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
|
||||
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
|
||||
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
|
||||
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);
|
||||
|
||||
@ -2368,6 +2371,7 @@ typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
|
||||
struct _virDomainXMLPrivateDataCallbacks {
|
||||
virDomainXMLPrivateDataAllocFunc alloc;
|
||||
virDomainXMLPrivateDataFreeFunc free;
|
||||
virDomainXMLPrivateDataNewFunc diskNew;
|
||||
virDomainXMLPrivateDataFormatFunc format;
|
||||
virDomainXMLPrivateDataParseFunc parse;
|
||||
};
|
||||
@ -2420,7 +2424,7 @@ void virDomainPanicDefFree(virDomainPanicDefPtr panic);
|
||||
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
|
||||
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
|
||||
void virDomainInputDefFree(virDomainInputDefPtr def);
|
||||
virDomainDiskDefPtr virDomainDiskDefNew(void);
|
||||
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
|
||||
void virDomainDiskDefFree(virDomainDiskDefPtr def);
|
||||
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
|
||||
int virDomainDiskGetType(virDomainDiskDefPtr def);
|
||||
|
@ -621,7 +621,7 @@ prlsdkAddDomainHardDisksInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
||||
PrlHandle_Free(hdd);
|
||||
hdd = PRL_INVALID_HANDLE;
|
||||
} else {
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto error;
|
||||
|
||||
if (prlsdkGetDiskInfo(hdd, disk, false) < 0)
|
||||
@ -661,7 +661,7 @@ prlsdkAddDomainOpticalDisksInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
||||
pret = PrlVmCfg_GetOpticalDisk(sdkdom, i, &cdrom);
|
||||
prlsdkCheckRetGoto(pret, error);
|
||||
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto error;
|
||||
|
||||
if (prlsdkGetDiskInfo(cdrom, disk, true) < 0)
|
||||
|
@ -12566,7 +12566,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
STRPREFIX(arg, "-fd") ||
|
||||
STREQ(arg, "-cdrom")) {
|
||||
WANT_VALUE();
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(xmlopt)))
|
||||
goto error;
|
||||
|
||||
if (STRPREFIX(val, "/dev/")) {
|
||||
@ -12868,7 +12868,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
goto error;
|
||||
}
|
||||
} else if (STRPREFIX(val, "disk:")) {
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(xmlopt)))
|
||||
goto error;
|
||||
if (VIR_STRDUP(disk->src->path, val + strlen("disk:")) < 0)
|
||||
goto error;
|
||||
|
@ -3126,7 +3126,7 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
||||
/* Allocate mem, if fails return error */
|
||||
if (VIR_ALLOC_N(def->disks, def->ndisks) >= 0) {
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
virDomainDiskDefPtr disk = virDomainDiskDefNew();
|
||||
virDomainDiskDefPtr disk = virDomainDiskDefNew(NULL);
|
||||
if (!disk) {
|
||||
error = true;
|
||||
break;
|
||||
@ -5850,7 +5850,7 @@ int vboxSnapshotGetReadOnlyDisks(virDomainSnapshotPtr snapshot,
|
||||
/* Allocate mem, if fails return error */
|
||||
if (VIR_ALLOC_N(def->dom->disks, def->dom->ndisks) >= 0) {
|
||||
for (i = 0; i < def->dom->ndisks; i++) {
|
||||
virDomainDiskDefPtr diskDef = virDomainDiskDefNew();
|
||||
virDomainDiskDefPtr diskDef = virDomainDiskDefNew(NULL);
|
||||
if (!diskDef)
|
||||
goto cleanup;
|
||||
def->dom->disks[i] = diskDef;
|
||||
|
@ -2187,7 +2187,7 @@ _dumpIDEHDDsOld(virDomainDefPtr def,
|
||||
if ((def->ndisks > 0) && (VIR_ALLOC_N(def->disks, def->ndisks) >= 0)) {
|
||||
size_t i;
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
if ((def->disks[i] = virDomainDiskDefNew())) {
|
||||
if ((def->disks[i] = virDomainDiskDefNew(NULL))) {
|
||||
def->disks[i]->device = VIR_DOMAIN_DISK_DEVICE_DISK;
|
||||
def->disks[i]->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||
virDomainDiskSetType(def->disks[i],
|
||||
@ -2295,7 +2295,7 @@ _dumpDVD(virDomainDefPtr def,
|
||||
|
||||
def->ndisks++;
|
||||
if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) {
|
||||
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew())) {
|
||||
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew(NULL))) {
|
||||
def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||
virDomainDiskSetType(def->disks[def->ndisks - 1],
|
||||
@ -2437,7 +2437,7 @@ _dumpFloppy(virDomainDefPtr def,
|
||||
|
||||
def->ndisks++;
|
||||
if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) {
|
||||
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew())) {
|
||||
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew(NULL))) {
|
||||
def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
|
||||
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_FDC;
|
||||
virDomainDiskSetType(def->disks[def->ndisks - 1],
|
||||
|
@ -1980,7 +1980,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(*def = virDomainDiskDefNew()))
|
||||
if (!(*def = virDomainDiskDefNew(xmlopt)))
|
||||
return -1;
|
||||
|
||||
(*def)->device = device;
|
||||
|
@ -372,7 +372,7 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||
bootable = sexpr_node(node, "device/tap/bootable");
|
||||
}
|
||||
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto error;
|
||||
|
||||
if (dst == NULL) {
|
||||
@ -1316,7 +1316,7 @@ xenParseSxpr(const struct sexpr *root,
|
||||
tmp = sexpr_node(root, "domain/image/hvm/cdrom");
|
||||
if ((tmp != NULL) && (tmp[0] != 0)) {
|
||||
virDomainDiskDefPtr disk;
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto error;
|
||||
if (virDomainDiskSetSource(disk, tmp) < 0) {
|
||||
virDomainDiskDefFree(disk);
|
||||
@ -1351,7 +1351,7 @@ xenParseSxpr(const struct sexpr *root,
|
||||
tmp = sexpr_fmt_node(root, "domain/image/hvm/%s", fds[i]);
|
||||
if ((tmp != NULL) && (tmp[0] != 0)) {
|
||||
virDomainDiskDefPtr disk;
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto error;
|
||||
if (virDomainDiskSetSource(disk, tmp) < 0) {
|
||||
virDomainDiskDefFree(disk);
|
||||
|
@ -286,7 +286,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
|
||||
if (xlu_disk_parse(xluconf, 1, &disk_spec, libxldisk))
|
||||
goto fail;
|
||||
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto fail;
|
||||
|
||||
if (VIR_STRDUP(disk->dst, libxldisk->vdev) < 0)
|
||||
|
@ -123,7 +123,7 @@ xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
||||
goto skipdisk;
|
||||
|
||||
head = list->str;
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
@ -275,7 +275,7 @@ xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
||||
if (xenConfigGetString(conf, "cdrom", &str, NULL) < 0)
|
||||
goto cleanup;
|
||||
if (str) {
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
if (!(disk = virDomainDiskDefNew(NULL)))
|
||||
goto cleanup;
|
||||
|
||||
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user