1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-04-28 22:50:15 +03:00

conf: use disk source accessors in xenxs/

Part of a series of cleanups to use new accessor methods.

* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk, xenFormatSxpr): Use accessors.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk, xenFormatXM):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-03-24 12:14:48 -06:00
parent 5b05358aba
commit 41a32b0a9b
2 changed files with 118 additions and 106 deletions

View File

@ -1,7 +1,7 @@
/* /*
* xen_sxpr.c: Xen SEXPR parsing functions * xen_sxpr.c: Xen SEXPR parsing functions
* *
* Copyright (C) 2010-2013 Red Hat, Inc. * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH * Copyright (C) 2011 Univention GmbH
* Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
* *
@ -401,24 +401,23 @@ xenParseSxprDisks(virDomainDefPtr def,
if (sexpr_lookup(node, "device/tap2") && if (sexpr_lookup(node, "device/tap2") &&
STRPREFIX(src, "tap:")) { STRPREFIX(src, "tap:")) {
if (VIR_STRDUP(disk->driverName, "tap2") < 0) if (virDomainDiskSetDriver(disk, "tap2") < 0)
goto error; goto error;
} else { } else {
if (VIR_ALLOC_N(disk->driverName, (offset-src)+1) < 0) char *tmp;
if (VIR_STRNDUP(tmp, src, offset - src) < 0)
goto error; goto error;
if (virStrncpy(disk->driverName, src, offset-src, if (virDomainDiskSetDriver(disk, tmp) < 0) {
(offset-src)+1) == NULL) { VIR_FREE(tmp);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Driver name %s too big for destination"),
src);
goto error; goto error;
} }
VIR_FREE(tmp);
} }
src = offset + 1; src = offset + 1;
if (STREQ(disk->driverName, "tap") || if (STREQ(virDomainDiskGetDriver(disk), "tap") ||
STREQ(disk->driverName, "tap2")) { STREQ(virDomainDiskGetDriver(disk), "tap2")) {
char *driverType = NULL; char *driverType = NULL;
offset = strchr(src, ':'); offset = strchr(src, ':');
@ -431,12 +430,12 @@ xenParseSxprDisks(virDomainDefPtr def,
if (VIR_STRNDUP(driverType, src, offset - src) < 0) if (VIR_STRNDUP(driverType, src, offset - src) < 0)
goto error; goto error;
if (STREQ(driverType, "aio")) if (STREQ(driverType, "aio"))
disk->format = VIR_STORAGE_FILE_RAW; virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
else else
disk->format = virDomainDiskSetFormat(disk,
virStorageFileFormatTypeFromString(driverType); virStorageFileFormatTypeFromString(driverType));
VIR_FREE(driverType); VIR_FREE(driverType);
if (disk->format <= 0) { if (virDomainDiskGetFormat(disk) <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown driver type %s"), src); _("Unknown driver type %s"), src);
goto error; goto error;
@ -448,17 +447,17 @@ xenParseSxprDisks(virDomainDefPtr def,
so we assume common case here. If blktap becomes so we assume common case here. If blktap becomes
omnipotent, we can revisit this, perhaps stat()'ing omnipotent, we can revisit this, perhaps stat()'ing
the src file in question */ the src file in question */
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
} else if (STREQ(disk->driverName, "phy")) { } else if (STREQ(virDomainDiskGetDriver(disk), "phy")) {
disk->type = VIR_DOMAIN_DISK_TYPE_BLOCK; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_BLOCK);
} else if (STREQ(disk->driverName, "file")) { } else if (STREQ(virDomainDiskGetDriver(disk), "file")) {
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
} }
} else { } else {
/* No CDROM media so can't really tell. We'll just /* No CDROM media so can't really tell. We'll just
call if a FILE for now and update when media call if a FILE for now and update when media
is inserted later */ is inserted later */
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
} }
if (STREQLEN(dst, "ioemu:", 6)) if (STREQLEN(dst, "ioemu:", 6))
@ -482,7 +481,7 @@ xenParseSxprDisks(virDomainDefPtr def,
if (VIR_STRDUP(disk->dst, dst) < 0) if (VIR_STRDUP(disk->dst, dst) < 0)
goto error; goto error;
if (VIR_STRDUP(disk->src, src) < 0) if (virDomainDiskSetSource(disk, src) < 0)
goto error; goto error;
if (STRPREFIX(disk->dst, "xvd")) if (STRPREFIX(disk->dst, "xvd"))
@ -1307,17 +1306,17 @@ xenParseSxpr(const struct sexpr *root,
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
if (VIR_ALLOC(disk) < 0) if (VIR_ALLOC(disk) < 0)
goto error; goto error;
if (VIR_STRDUP(disk->src, tmp) < 0) { if (virDomainDiskSetSource(disk, tmp) < 0) {
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
goto error; goto error;
} }
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
if (VIR_STRDUP(disk->dst, "hdc") < 0) { if (VIR_STRDUP(disk->dst, "hdc") < 0) {
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
goto error; goto error;
} }
if (VIR_STRDUP(disk->driverName, "file") < 0) { if (virDomainDiskSetDriver(disk, "file") < 0) {
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
goto error; goto error;
} }
@ -1342,17 +1341,17 @@ xenParseSxpr(const struct sexpr *root,
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
if (VIR_ALLOC(disk) < 0) if (VIR_ALLOC(disk) < 0)
goto error; goto error;
if (VIR_STRDUP(disk->src, tmp) < 0) { if (virDomainDiskSetSource(disk, tmp) < 0) {
VIR_FREE(disk); VIR_FREE(disk);
goto error; goto error;
} }
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
if (VIR_STRDUP(disk->dst, fds[i]) < 0) { if (VIR_STRDUP(disk->dst, fds[i]) < 0) {
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
goto error; goto error;
} }
if (VIR_STRDUP(disk->driverName, "file") < 0) { if (virDomainDiskSetSource(disk, "file") < 0) {
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
goto error; goto error;
} }
@ -1722,6 +1721,9 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
int xendConfigVersion, int xendConfigVersion,
int isAttach) int isAttach)
{ {
const char *src = virDomainDiskGetSource(def);
const char *driver = virDomainDiskGetDriver(def);
/* Xend (all versions) put the floppy device config /* Xend (all versions) put the floppy device config
* under the hvm (image (os)) block * under the hvm (image (os)) block
*/ */
@ -1729,7 +1731,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
if (isAttach) { if (isAttach) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("Cannot directly attach floppy %s"), def->src); _("Cannot directly attach floppy %s"), src);
return -1; return -1;
} }
return 0; return 0;
@ -1741,7 +1743,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) { xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
if (isAttach) { if (isAttach) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("Cannot directly attach CDROM %s"), def->src); _("Cannot directly attach CDROM %s"), src);
return -1; return -1;
} }
return 0; return 0;
@ -1753,9 +1755,9 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
/* Normally disks are in a (device (vbd ...)) block /* Normally disks are in a (device (vbd ...)) block
* but blktap disks ended up in a differently named * but blktap disks ended up in a differently named
* (device (tap ....)) block.... */ * (device (tap ....)) block.... */
if (def->driverName && STREQ(def->driverName, "tap")) { if (STREQ_NULLABLE(driver, "tap")) {
virBufferAddLit(buf, "(tap "); virBufferAddLit(buf, "(tap ");
} else if (def->driverName && STREQ(def->driverName, "tap2")) { } else if (STREQ_NULLABLE(driver, "tap2")) {
virBufferAddLit(buf, "(tap2 "); virBufferAddLit(buf, "(tap2 ");
} else { } else {
virBufferAddLit(buf, "(vbd "); virBufferAddLit(buf, "(vbd ");
@ -1778,36 +1780,39 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
virBufferEscapeSexpr(buf, "(dev '%s')", def->dst); virBufferEscapeSexpr(buf, "(dev '%s')", def->dst);
} }
if (def->src) { if (src) {
if (def->driverName) { if (driver) {
if (STREQ(def->driverName, "tap") || if (STREQ(driver, "tap") ||
STREQ(def->driverName, "tap2")) { STREQ(driver, "tap2")) {
const char *type; const char *type;
int format = virDomainDiskGetFormat(def);
if (!def->format || def->format == VIR_STORAGE_FILE_RAW) if (!format || format == VIR_STORAGE_FILE_RAW)
type = "aio"; type = "aio";
else else
type = virStorageFileFormatTypeToString(def->format); type = virStorageFileFormatTypeToString(format);
virBufferEscapeSexpr(buf, "(uname '%s:", def->driverName); virBufferEscapeSexpr(buf, "(uname '%s:", driver);
virBufferEscapeSexpr(buf, "%s:", type); virBufferEscapeSexpr(buf, "%s:", type);
virBufferEscapeSexpr(buf, "%s')", def->src); virBufferEscapeSexpr(buf, "%s')", src);
} else { } else {
virBufferEscapeSexpr(buf, "(uname '%s:", def->driverName); virBufferEscapeSexpr(buf, "(uname '%s:", driver);
virBufferEscapeSexpr(buf, "%s')", def->src); virBufferEscapeSexpr(buf, "%s')", src);
} }
} else { } else {
if (def->type == VIR_DOMAIN_DISK_TYPE_FILE) { int type = virDomainDiskGetType(def);
virBufferEscapeSexpr(buf, "(uname 'file:%s')", def->src);
} else if (def->type == VIR_DOMAIN_DISK_TYPE_BLOCK) { if (type == VIR_DOMAIN_DISK_TYPE_FILE) {
if (def->src[0] == '/') virBufferEscapeSexpr(buf, "(uname 'file:%s')", src);
virBufferEscapeSexpr(buf, "(uname 'phy:%s')", def->src); } else if (type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
if (src[0] == '/')
virBufferEscapeSexpr(buf, "(uname 'phy:%s')", src);
else else
virBufferEscapeSexpr(buf, "(uname 'phy:/dev/%s')", virBufferEscapeSexpr(buf, "(uname 'phy:/dev/%s')",
def->src); src);
} else { } else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported disk type %s"), _("unsupported disk type %s"),
virDomainDiskTypeToString(def->type)); virDomainDiskTypeToString(type));
return -1; return -1;
} }
} }
@ -2313,23 +2318,23 @@ xenFormatSxpr(virConnectPtr conn,
/* some disk devices are defined here */ /* some disk devices are defined here */
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
const char *src = virDomainDiskGetSource(def->disks[i]);
switch (def->disks[i]->device) { switch (def->disks[i]->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM: case VIR_DOMAIN_DISK_DEVICE_CDROM:
/* Only xend <= 3.0.2 wants cdrom config here */ /* Only xend <= 3.0.2 wants cdrom config here */
if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2) if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2)
break; break;
if (!STREQ(def->disks[i]->dst, "hdc") || if (!STREQ(def->disks[i]->dst, "hdc") || !src)
def->disks[i]->src == NULL)
break; break;
virBufferEscapeSexpr(&buf, "(cdrom '%s')", virBufferEscapeSexpr(&buf, "(cdrom '%s')", src);
def->disks[i]->src);
break; break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY: case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
/* all xend versions define floppies here */ /* all xend versions define floppies here */
virBufferEscapeSexpr(&buf, "(%s ", def->disks[i]->dst); virBufferEscapeSexpr(&buf, "(%s ", def->disks[i]->dst);
virBufferEscapeSexpr(&buf, "'%s')", def->disks[i]->src); virBufferEscapeSexpr(&buf, "'%s')", src);
break; break;
default: default:

View File

@ -1,7 +1,7 @@
/* /*
* xen_xm.c: Xen XM parsing functions * xen_xm.c: Xen XM parsing functions
* *
* Copyright (C) 2006-2007, 2009-2010, 2012-2014 Red Hat, Inc. * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH * Copyright (C) 2011 Univention GmbH
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
@ -480,6 +480,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
char *head; char *head;
char *offset; char *offset;
char *tmp; char *tmp;
const char *src;
if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
goto skipdisk; goto skipdisk;
@ -501,17 +502,16 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto skipdisk; goto skipdisk;
if (offset == head) { if (offset == head) {
disk->src = NULL; /* No source file given, eg CDROM with no media */ /* No source file given, eg CDROM with no media */
ignore_value(virDomainDiskSetSource(disk, NULL));
} else { } else {
if (VIR_ALLOC_N(disk->src, (offset - head) + 1) < 0) if (VIR_STRNDUP(tmp, head, offset - head) < 0)
goto cleanup; goto cleanup;
if (virStrncpy(disk->src, head, offset - head, if (virDomainDiskSetSource(disk, tmp) < 0) {
(offset - head) + 1) == NULL) { VIR_FREE(tmp);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Source file %s too big for destination"),
head);
goto cleanup; goto cleanup;
} }
VIR_FREE(tmp);
} }
head = offset + 1; head = offset + 1;
@ -532,65 +532,68 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
} }
head = offset + 1; head = offset + 1;
/* Extract source driver type */ /* Extract source driver type */
if (disk->src) { src = virDomainDiskGetSource(disk);
if (src) {
size_t len;
/* The main type phy:, file:, tap: ... */ /* The main type phy:, file:, tap: ... */
if ((tmp = strchr(disk->src, ':')) != NULL) { if ((tmp = strchr(src, ':')) != NULL) {
if (VIR_ALLOC_N(disk->driverName, (tmp - disk->src) + 1) < 0) len = tmp - src;
if (VIR_STRNDUP(tmp, src, len) < 0)
goto cleanup; goto cleanup;
if (virStrncpy(disk->driverName, disk->src, if (virDomainDiskSetDriver(disk, tmp) < 0) {
(tmp - disk->src), VIR_FREE(tmp);
(tmp - disk->src) + 1) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Driver name %s too big for destination"),
disk->src);
goto cleanup; goto cleanup;
} }
VIR_FREE(tmp);
/* Strip the prefix we found off the source file name */ /* Strip the prefix we found off the source file name */
memmove(disk->src, disk->src+(tmp-disk->src)+1, if (virDomainDiskSetSource(disk, src + len + 1) < 0)
strlen(disk->src)-(tmp-disk->src)); goto cleanup;
src = virDomainDiskGetSource(disk);
} }
/* And the sub-type for tap:XXX: type */ /* And the sub-type for tap:XXX: type */
if (disk->driverName && if (STREQ_NULLABLE(virDomainDiskGetDriver(disk), "tap")) {
STREQ(disk->driverName, "tap")) {
char *driverType; char *driverType;
if (!(tmp = strchr(disk->src, ':'))) if (!(tmp = strchr(src, ':')))
goto skipdisk; goto skipdisk;
len = tmp - src;
if (VIR_STRNDUP(driverType, disk->src, tmp - disk->src) < 0) if (VIR_STRNDUP(driverType, src, len) < 0)
goto cleanup; goto cleanup;
if (STREQ(driverType, "aio")) if (STREQ(driverType, "aio"))
disk->format = VIR_STORAGE_FILE_RAW; virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
else else
disk->format = virDomainDiskSetFormat(disk,
virStorageFileFormatTypeFromString(driverType); virStorageFileFormatTypeFromString(driverType));
VIR_FREE(driverType); VIR_FREE(driverType);
if (disk->format <= 0) { if (virDomainDiskGetFormat(disk) <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown driver type %s"), _("Unknown driver type %s"),
disk->src); src);
goto cleanup; goto cleanup;
} }
/* Strip the prefix we found off the source file name */ /* Strip the prefix we found off the source file name */
memmove(disk->src, disk->src+(tmp-disk->src)+1, if (virDomainDiskSetSource(disk, src + len + 1) < 0)
strlen(disk->src)-(tmp-disk->src)); goto cleanup;
src = virDomainDiskGetSource(disk);
} }
} }
/* No source, or driver name, so fix to phy: */ /* No source, or driver name, so fix to phy: */
if (!disk->driverName && if (!virDomainDiskGetDriver(disk) &&
VIR_STRDUP(disk->driverName, "phy") < 0) virDomainDiskSetDriver(disk, "phy") < 0)
goto cleanup; goto cleanup;
/* phy: type indicates a block device */ /* phy: type indicates a block device */
disk->type = STREQ(disk->driverName, "phy") ? virDomainDiskSetType(disk,
VIR_DOMAIN_DISK_TYPE_BLOCK : VIR_DOMAIN_DISK_TYPE_FILE; STREQ(virDomainDiskGetDriver(disk), "phy") ?
VIR_DOMAIN_DISK_TYPE_BLOCK :
VIR_DOMAIN_DISK_TYPE_FILE);
/* Check for a :cdrom/:disk postfix */ /* Check for a :cdrom/:disk postfix */
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK; disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
@ -632,11 +635,11 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (VIR_ALLOC(disk) < 0) if (VIR_ALLOC(disk) < 0)
goto cleanup; goto cleanup;
disk->type = VIR_DOMAIN_DISK_TYPE_FILE; virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_FILE);
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
if (VIR_STRDUP(disk->driverName, "file") < 0) if (virDomainDiskSetDriver(disk, "file") < 0)
goto cleanup; goto cleanup;
if (VIR_STRDUP(disk->src, str) < 0) if (virDomainDiskSetSource(disk, str) < 0)
goto cleanup; goto cleanup;
if (VIR_STRDUP(disk->dst, "hdc") < 0) if (VIR_STRDUP(disk->dst, "hdc") < 0)
goto cleanup; goto cleanup;
@ -1186,27 +1189,31 @@ xenXMConfigSetString(virConfPtr conf, const char *setting, const char *str)
} }
static int xenFormatXMDisk(virConfValuePtr list, static int
xenFormatXMDisk(virConfValuePtr list,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
int hvm, int hvm,
int xendConfigVersion) int xendConfigVersion)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp; virConfValuePtr val, tmp;
const char *src = virDomainDiskGetSource(disk);
int format = virDomainDiskGetFormat(disk);
const char *driver = virDomainDiskGetDriver(disk);
if (disk->src) { if (src) {
if (disk->format) { if (format) {
const char *type; const char *type;
if (disk->format == VIR_STORAGE_FILE_RAW) if (format == VIR_STORAGE_FILE_RAW)
type = "aio"; type = "aio";
else else
type = virStorageFileFormatTypeToString(disk->format); type = virStorageFileFormatTypeToString(format);
virBufferAsprintf(&buf, "%s:", disk->driverName); virBufferAsprintf(&buf, "%s:", driver);
if (STREQ(disk->driverName, "tap")) if (STREQ(driver, "tap"))
virBufferAsprintf(&buf, "%s:", type); virBufferAsprintf(&buf, "%s:", type);
} else { } else {
switch (disk->type) { switch (virDomainDiskGetType(disk)) {
case VIR_DOMAIN_DISK_TYPE_FILE: case VIR_DOMAIN_DISK_TYPE_FILE:
virBufferAddLit(&buf, "file:"); virBufferAddLit(&buf, "file:");
break; break;
@ -1216,11 +1223,11 @@ static int xenFormatXMDisk(virConfValuePtr list,
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported disk type %s"), _("unsupported disk type %s"),
virDomainDiskTypeToString(disk->type)); virDomainDiskTypeToString(virDomainDiskGetType(disk)));
goto cleanup; goto cleanup;
} }
} }
virBufferAdd(&buf, disk->src, -1); virBufferAdd(&buf, src, -1);
} }
virBufferAddLit(&buf, ","); virBufferAddLit(&buf, ",");
if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2)
@ -1613,9 +1620,9 @@ virConfPtr xenFormatXM(virConnectPtr conn,
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst && def->disks[i]->dst &&
STREQ(def->disks[i]->dst, "hdc") && STREQ(def->disks[i]->dst, "hdc") &&
def->disks[i]->src) { virDomainDiskGetSource(def->disks[i])) {
if (xenXMConfigSetString(conf, "cdrom", if (xenXMConfigSetString(conf, "cdrom",
def->disks[i]->src) < 0) virDomainDiskGetSource(def->disks[i])) < 0)
goto cleanup; goto cleanup;
break; break;
} }