mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 21:15:20 +00:00
parallels: split parallelsStorageOpen function
Move code for loading inforation about pools to a separate function - parallelsLoadPools. Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
parent
45e6317158
commit
21e1bdeb3d
@ -114,33 +114,14 @@ cleanup:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static int parallelsLoadPools(virConnectPtr conn)
|
||||||
parallelsStorageOpen(virConnectPtr conn,
|
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
char *base = NULL;
|
|
||||||
virStorageDriverStatePtr storageState;
|
|
||||||
bool privileged = (geteuid() == 0);
|
|
||||||
parallelsConnPtr privconn = conn->privateData;
|
parallelsConnPtr privconn = conn->privateData;
|
||||||
|
virStorageDriverStatePtr storageState = conn->storagePrivateData;
|
||||||
|
bool privileged = (geteuid() == 0);
|
||||||
|
char *base = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
|
||||||
|
|
||||||
if (STRNEQ(conn->driver->name, "Parallels"))
|
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (VIR_ALLOC(storageState) < 0) {
|
|
||||||
virReportOOMError();
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virMutexInit(&storageState->lock) < 0) {
|
|
||||||
VIR_FREE(storageState);
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
}
|
|
||||||
parallelsStorageLock(storageState);
|
|
||||||
|
|
||||||
if (privileged) {
|
if (privileged) {
|
||||||
if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
|
if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
@ -194,16 +175,47 @@ parallelsStorageOpen(virConnectPtr conn,
|
|||||||
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
parallelsStorageUnlock(storageState);
|
return 0;
|
||||||
|
|
||||||
conn->storagePrivateData = storageState;
|
|
||||||
|
|
||||||
return VIR_DRV_OPEN_SUCCESS;
|
|
||||||
|
|
||||||
out_of_memory:
|
out_of_memory:
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
error:
|
error:
|
||||||
VIR_FREE(base);
|
VIR_FREE(base);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static virDrvOpenStatus
|
||||||
|
parallelsStorageOpen(virConnectPtr conn,
|
||||||
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
virStorageDriverStatePtr storageState;
|
||||||
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
|
if (STRNEQ(conn->driver->name, "Parallels"))
|
||||||
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(storageState) < 0) {
|
||||||
|
virReportOOMError();
|
||||||
|
return VIR_DRV_OPEN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virMutexInit(&storageState->lock) < 0) {
|
||||||
|
VIR_FREE(storageState);
|
||||||
|
return VIR_DRV_OPEN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn->storagePrivateData = storageState;
|
||||||
|
parallelsStorageLock(storageState);
|
||||||
|
|
||||||
|
if (parallelsLoadPools(conn))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
parallelsStorageUnlock(storageState);
|
||||||
|
|
||||||
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
|
|
||||||
|
error:
|
||||||
parallelsStorageUnlock(storageState);
|
parallelsStorageUnlock(storageState);
|
||||||
parallelsStorageClose(conn);
|
parallelsStorageClose(conn);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user