On Tue, Dec 04, 2012 at 05:43:01PM +0400, Dmitry Guryanov wrote: > Parse information about hard disks and fill disks array > in virDomainDef structure. > > Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx> > --- > src/parallels/parallels_driver.c | 118 ++++++++++++++++++++++++++++++++++++++ > 1 files changed, 118 insertions(+), 0 deletions(-) > > diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c > index 50efd1d..1a5851a 100644 > --- a/src/parallels/parallels_driver.c > +++ b/src/parallels/parallels_driver.c > @@ -72,6 +72,8 @@ > virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__, \ > __FUNCTION__, __LINE__, _("Can't parse prlctl output")) > > +#define IS_CT(def) (STREQ_NULLABLE(def->os.type, "exe")) > + > static int parallelsClose(virConnectPtr conn); > > void > @@ -298,6 +300,119 @@ cleanup: > } > > static int > +parallelsGetHddInfo(virDomainDefPtr def, > + virDomainDiskDefPtr disk, > + const char *key, > + virJSONValuePtr value) > +{ > + const char *tmp; > + > + disk->device = VIR_DOMAIN_DISK_DEVICE_DISK; > + > + if (virJSONValueObjectHasKey(value, "real") == 1) { > + disk->type = VIR_DOMAIN_DISK_TYPE_BLOCK; > + > + if (!(tmp = virJSONValueObjectGetString(value, "real"))) { > + parallelsParseError(); > + return -1; > + } > + > + if (!(disk->src = strdup(tmp))) { > + virReportOOMError(); > + return -1; > + } > + } else { > + disk->type = VIR_DOMAIN_DISK_TYPE_FILE; > + > + if (!(tmp = virJSONValueObjectGetString(value, "image"))) { > + parallelsParseError(); > + return -1; > + } > + > + if (!(disk->src = strdup(tmp))) { > + virReportOOMError(); > + return -1; > + } > + } > + > + tmp = virJSONValueObjectGetString(value, "port"); > + if (!tmp && !IS_CT(def)) { > + parallelsParseError(); > + return -1; > + } > + > + if (tmp) { > + if (STRPREFIX(tmp, "ide")) { > + disk->bus = VIR_DOMAIN_DISK_BUS_IDE; > + } else if (STRPREFIX(tmp, "sata")) { > + disk->bus = VIR_DOMAIN_DISK_BUS_SATA; > + } else if (STRPREFIX(tmp, "scsi")) { > + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; > + } else { > + parallelsParseError(); > + return -1; > + } > + > + char *colonp; > + unsigned int pos; > + > + if (!(colonp = strchr(tmp, ':'))) { > + parallelsParseError(); > + return -1; > + } > + > + if (virStrToLong_ui(colonp + 1, NULL, 10, &pos) < 0) { > + parallelsParseError(); > + return -1; > + } > + > + disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; > + disk->info.addr.drive.target = pos; > + } else { > + /* Actually there are no disk devices in containers, but in > + * in Parallels Cloud Server we mount disk images as container's > + * root fs during start, so it looks like a disk device. */ > + disk->bus = VIR_DOMAIN_DISK_BUS_IDE; > + } > + > + unsigned int idx; Okay, but as far as I know we still prefer variable declaration in block head so I's squashing in the following patch: diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 8274c88..60bf8b5 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -320,6 +320,7 @@ parallelsGetHddInfo(virDomainDefPtr def, virJSONValuePtr value) { const char *tmp; + unsigned int idx; disk->device = VIR_DOMAIN_DISK_DEVICE_DISK; @@ -389,7 +390,6 @@ parallelsGetHddInfo(virDomainDefPtr def, disk->bus = VIR_DOMAIN_DISK_BUS_IDE; } - unsigned int idx; if (virStrToLong_ui(key + strlen("hdd"), NULL, 10, &idx) < 0) { parallelsParseError(); return -1; Daniel -- Daniel Veillard | Open Source and Standards, Red Hat veillard@xxxxxxxxxx | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list