vz: getting bus type for containers

We should query bus type for containers too, like for VM.
In openstack we add volume disk like SCSI, so we can't
hardcode SATA bus.
This commit is contained in:
Mikhail Feoktistov 2016-08-15 12:02:49 -04:00 committed by Maxim Nestratov
parent 836a2c78ca
commit 0c3e499c78

View File

@ -49,7 +49,7 @@ VIR_LOG_INIT("parallels.sdk");
static PRL_HANDLE static PRL_HANDLE
prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac); prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac);
static PRL_HANDLE static PRL_HANDLE
prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool isCt); prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk);
/* /*
* Log error description * Log error description
@ -546,7 +546,7 @@ prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomainDefPtr def)
} }
static int static int
prlsdkGetDiskId(PRL_HANDLE disk, bool isCt, int *bus, char **dst) prlsdkGetDiskId(PRL_HANDLE disk, int *bus, char **dst)
{ {
PRL_RESULT pret; PRL_RESULT pret;
PRL_UINT32 pos, ifType; PRL_UINT32 pos, ifType;
@ -554,13 +554,8 @@ prlsdkGetDiskId(PRL_HANDLE disk, bool isCt, int *bus, char **dst)
pret = PrlVmDev_GetStackIndex(disk, &pos); pret = PrlVmDev_GetStackIndex(disk, &pos);
prlsdkCheckRetExit(pret, -1); prlsdkCheckRetExit(pret, -1);
/* Let physical devices added to CT look like SATA disks */ pret = PrlVmDev_GetIfaceType(disk, &ifType);
if (isCt) { prlsdkCheckRetExit(pret, -1);
ifType = PMS_SATA_DEVICE;
} else {
pret = PrlVmDev_GetIfaceType(disk, &ifType);
prlsdkCheckRetExit(pret, -1);
}
switch (ifType) { switch (ifType) {
case PMS_IDE_DEVICE: case PMS_IDE_DEVICE:
@ -631,7 +626,7 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
if (*buf != '\0' && virDomainDiskSetSource(disk, buf) < 0) if (*buf != '\0' && virDomainDiskSetSource(disk, buf) < 0)
goto cleanup; goto cleanup;
if (prlsdkGetDiskId(prldisk, isCt, &disk->bus, &disk->dst) < 0) if (prlsdkGetDiskId(prldisk, &disk->bus, &disk->dst) < 0)
goto cleanup; goto cleanup;
if (virDiskNameToBusDeviceIndex(disk, &busIdx, &devIdx) < 0) if (virDiskNameToBusDeviceIndex(disk, &busIdx, &devIdx) < 0)
@ -1599,7 +1594,7 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
goto cleanup; goto cleanup;
} }
if (prlsdkGetDiskId(dev, false, &bus, &dst) < 0) if (prlsdkGetDiskId(dev, &bus, &dst) < 0)
goto cleanup; goto cleanup;
if (!(bus == disk->bus && STREQ(disk->dst, dst))) if (!(bus == disk->bus && STREQ(disk->dst, dst)))
@ -3415,7 +3410,6 @@ prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac)
static int prlsdkConfigureDisk(vzDriverPtr driver, static int prlsdkConfigureDisk(vzDriverPtr driver,
PRL_HANDLE sdkdom, PRL_HANDLE sdkdom,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
bool isCt,
bool create) bool create)
{ {
PRL_RESULT pret; PRL_RESULT pret;
@ -3438,7 +3432,7 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
pret = PrlVmCfg_CreateVmDev(sdkdom, devType, &sdkdisk); pret = PrlVmCfg_CreateVmDev(sdkdom, devType, &sdkdisk);
prlsdkCheckRetGoto(pret, cleanup); prlsdkCheckRetGoto(pret, cleanup);
} else { } else {
sdkdisk = prlsdkGetDisk(sdkdom, disk, isCt); sdkdisk = prlsdkGetDisk(sdkdom, disk);
if (sdkdisk == PRL_INVALID_HANDLE) if (sdkdisk == PRL_INVALID_HANDLE)
return -1; return -1;
} }
@ -3505,7 +3499,7 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
} }
static PRL_HANDLE static PRL_HANDLE
prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool isCt) prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
{ {
PRL_RESULT pret; PRL_RESULT pret;
PRL_UINT32 num; PRL_UINT32 num;
@ -3527,7 +3521,7 @@ prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool isCt)
pret = PrlVmCfg_GetDevByType(sdkdom, devType, i, &sdkdisk); pret = PrlVmCfg_GetDevByType(sdkdom, devType, i, &sdkdisk);
prlsdkCheckRetGoto(pret, error); prlsdkCheckRetGoto(pret, error);
if (prlsdkGetDiskId(sdkdisk, isCt, &bus, &dst) < 0) if (prlsdkGetDiskId(sdkdisk, &bus, &dst) < 0)
goto error; goto error;
if (disk->bus == bus && STREQ(disk->dst, dst)) { if (disk->bus == bus && STREQ(disk->dst, dst)) {
@ -3566,7 +3560,7 @@ prlsdkAttachDevice(vzDriverPtr driver,
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
if (prlsdkConfigureDisk(driver, privdom->sdkdom, if (prlsdkConfigureDisk(driver, privdom->sdkdom,
dev->data.disk, IS_CT(dom->def), true) < 0) dev->data.disk, true) < 0)
return -1; return -1;
break; break;
@ -3630,7 +3624,7 @@ prlsdkDetachDevice(vzDriverPtr driver,
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
sdkdev = prlsdkGetDisk(privdom->sdkdom, dev->data.disk, IS_CT(dom->def)); sdkdev = prlsdkGetDisk(privdom->sdkdom, dev->data.disk);
if (sdkdev == PRL_INVALID_HANDLE) if (sdkdev == PRL_INVALID_HANDLE)
goto cleanup; goto cleanup;
@ -3706,7 +3700,7 @@ prlsdkUpdateDevice(vzDriverPtr driver,
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
if (prlsdkConfigureDisk(driver, privdom->sdkdom, dev->data.disk, if (prlsdkConfigureDisk(driver, privdom->sdkdom, dev->data.disk,
IS_CT(dom->def), false) < 0) false) < 0)
return -1; return -1;
break; break;
@ -3999,7 +3993,7 @@ prlsdkDoApplyConfig(vzDriverPtr driver,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
if (prlsdkConfigureDisk(driver, sdkdom, def->disks[i], if (prlsdkConfigureDisk(driver, sdkdom, def->disks[i],
IS_CT(def), true) < 0) true) < 0)
goto error; goto error;
} }