提交 45e63171 编写于 作者: D Dmitry Guryanov 提交者: Daniel Veillard

parallels: handle disk devices in parallelsDomainDefineXML

Allow changing some parameters of the hard disks: bus,
image and drive address.

Creating new disk devices and removing existing ones
require changes in the storage driver, so it will be
implemented later.
Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
上级 6718b2d7
......@@ -1477,6 +1477,72 @@ parallelsApplyVideoParams(parallelsDomObjPtr pdom,
return 0;
}
static int
parallelsApplyDisksParams(parallelsDomObjPtr pdom,
virDomainDiskDefPtr *olddisks, int nold,
virDomainDiskDefPtr *newdisks, int nnew)
{
/* TODO: allow creating and removing disks */
if (nold != nnew) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Adding and removing disks is not supported"));
return -1;
}
for (int i = 0; i < nold; i++) {
virDomainDiskDefPtr newdisk = NULL;
virDomainDiskDefPtr olddisk = olddisks[i];
for (int j = 0; j < nnew; j++) {
if (STREQ_NULLABLE(newdisks[j]->dst, olddisk->dst)) {
newdisk = newdisks[j];
break;
}
}
if (!newdisk) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
_("There is no disk with source '%s' "
"in the specified config"), olddisks[i]->serial);
return -1;
}
if (olddisk->bus != newdisk->bus ||
olddisk->info.addr.drive.target != newdisk->info.addr.drive.target ||
!STREQ_NULLABLE(olddisk->src, newdisk->src)) {
char prlname[16];
char strpos[16];
const char *strbus;
prlname[15] = '\0';
snprintf(prlname, 15, "hdd%d", virDiskNameToIndex(newdisk->dst));
strpos[15] = '\0';
snprintf(strpos, 15, "%d", newdisk->info.addr.drive.target);
switch (newdisk->bus) {
case VIR_DOMAIN_DISK_BUS_IDE:
strbus = "ide";
break;
case VIR_DOMAIN_DISK_BUS_SATA:
strbus = "sata";
break;
case VIR_DOMAIN_DISK_BUS_SCSI:
strbus = "scsi";
break;
}
if (parallelsCmdRun(PRLCTL, "set", pdom->uuid,
"--device-set", prlname,
"--iface", strbus,
"--position", strpos,
"--image", newdisk->src, NULL))
return -1;
}
}
return 0;
}
static int
parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
{
......@@ -1676,8 +1742,7 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
new->graphics, new->ngraphics) < 0)
return -1;
if (new->ndisks != 0 || new->ncontrollers != 0 ||
new->nfss != 0 || new->nnets != 0 ||
if (new->nfss != 0 || new->nnets != 0 ||
new->nsounds != 0 || new->nhostdevs != 0 ||
new->nredirdevs != 0 || new->nsmartcards != 0 ||
new->nparallels || new->nchannels != 0 ||
......@@ -1712,6 +1777,10 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
if (parallelsApplyVideoParams(pdom, old->videos, old->nvideos,
new->videos, new->nvideos) < 0)
return -1;
if (parallelsApplyDisksParams(pdom, old->disks, old->ndisks,
new->disks, new->ndisks) < 0)
return -1;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册