int on)
{
int ret;
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd =
virCommandNewArgList(VGCHANGE,
on ? "-aly" : "-aln",
- pool->def->source.name,
+ def->source.name,
NULL);
ret = virCommandRun(cmd, NULL);
{
struct virStorageBackendLogicalPoolVolData *data = opaque;
virStoragePoolObjPtr pool = data->pool;
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virStorageVolDefPtr vol = NULL;
bool is_new_vol = false;
int ret = -1;
if (vol->target.path == NULL) {
if (virAsprintf(&vol->target.path, "%s/%s",
- pool->def->target.path, vol->name) < 0)
+ def->target.path, vol->name) < 0)
goto cleanup;
}
goto cleanup;
if (virAsprintf(&vol->target.backingStore->path, "%s/%s",
- pool->def->target.path, groups[1]) < 0)
+ def->target.path, groups[1]) < 0)
goto cleanup;
vol->target.backingStore->format = VIR_STORAGE_POOL_LOGICAL_LVM2;
};
int ret = -1;
virCommandPtr cmd;
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
struct virStorageBackendLogicalPoolVolData cbdata = {
.pool = pool,
.vol = vol,
"--nosuffix",
"--options",
"lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr",
- pool->def->source.name,
+ def->source.name,
NULL);
if (virCommandRunRegex(cmd,
1,
void *data)
{
virStoragePoolObjPtr pool = data;
- if (virStrToLong_ull(groups[0], NULL, 10, &pool->def->capacity) < 0)
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
+
+ if (virStrToLong_ull(groups[0], NULL, 10, &def->capacity) < 0)
return -1;
- if (virStrToLong_ull(groups[1], NULL, 10, &pool->def->available) < 0)
+ if (virStrToLong_ull(groups[1], NULL, 10, &def->available) < 0)
return -1;
- pool->def->allocation = pool->def->capacity - pool->def->available;
+ def->allocation = def->capacity - def->available;
return 0;
}
static bool
virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virStoragePoolSourceList sourceList;
virStoragePoolSource *thisSource = NULL;
size_t i, j;
/* Search the pvs output for this pool's source.name */
for (i = 0; i < sourceList.nsources; i++) {
thisSource = &sourceList.sources[i];
- if (STREQ(thisSource->name, pool->def->source.name))
+ if (STREQ(thisSource->name, def->source.name))
break;
}
if (i == sourceList.nsources) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("cannot find logical volume group name '%s'"),
- pool->def->source.name);
+ def->source.name);
goto cleanup;
}
* they match as well; otherwise, matching can only occur on the
* pool's name.
*/
- if (!pool->def->source.ndevice) {
+ if (!def->source.ndevice) {
ret = true;
goto cleanup;
}
/* Let's make sure the pool's device(s) match what the pvs output has
* for volume group devices.
*/
- for (i = 0; i < pool->def->source.ndevice; i++) {
+ for (i = 0; i < def->source.ndevice; i++) {
for (j = 0; j < thisSource->ndevice; j++) {
- if (STREQ(pool->def->source.devices[i].path,
+ if (STREQ(def->source.devices[i].path,
thisSource->devices[j].path))
matchcount++;
}
if (matchcount == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("cannot find any matching source devices for logical "
- "volume group '%s'"), pool->def->source.name);
+ "volume group '%s'"), def->source.name);
goto cleanup;
}
* to 'add' to or 'remove' from the volume group outside of libvirt's
* knowledge. Rather than fail on that, provide a warning and move on.
*/
- if (matchcount != pool->def->source.ndevice)
+ if (matchcount != def->source.ndevice)
VIR_WARN("pool device list count doesn't match pvs device list count");
ret = true;
virStorageBackendLogicalCheckPool(virStoragePoolObjPtr pool,
bool *isActive)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
+
/* If we can find the target.path as well as ensure that the
* pool's def source
*/
- *isActive = virFileExists(pool->def->target.path) &&
+ *isActive = virFileExists(def->target.path) &&
virStorageBackendLogicalMatchPoolSource(pool);
return 0;
}
virStoragePoolObjPtr pool,
unsigned int flags)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr vgcmd = NULL;
int ret = -1;
size_t i = 0;
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
cleanup);
- vgcmd = virCommandNewArgList(VGCREATE, pool->def->source.name, NULL);
+ vgcmd = virCommandNewArgList(VGCREATE, def->source.name, NULL);
- for (i = 0; i < pool->def->source.ndevice; i++) {
- const char *path = pool->def->source.devices[i].path;
+ for (i = 0; i < def->source.ndevice; i++) {
+ const char *path = def->source.devices[i].path;
/* The blkid FS and Part probing code doesn't know "lvm2" (this
* pool's only format type), but it does know "LVM2_member", so
if (ret < 0) {
size_t j;
for (j = 0; j < i; j++)
- virStorageBackendLogicalRemoveDevice(pool->def->source.devices[j].path);
+ virStorageBackendLogicalRemoveDevice(def->source.devices[j].path);
}
return ret;
}
int vars[] = {
2
};
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
int ret = -1;
"--unbuffered",
"--nosuffix",
"--options", "vg_size,vg_free",
- pool->def->source.name,
+ def->source.name,
NULL);
/* Now get basic volgrp metadata */
virStoragePoolObjPtr pool,
unsigned int flags)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
size_t i;
int ret = -1;
/* first remove the volume group */
cmd = virCommandNewArgList(VGREMOVE,
- "-f", pool->def->source.name,
+ "-f", def->source.name,
NULL);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
/* now remove the pv devices and clear them out */
- for (i = 0; i < pool->def->source.ndevice; i++)
- virStorageBackendLogicalRemoveDevice(pool->def->source.devices[i].path);
+ for (i = 0; i < def->source.ndevice; i++)
+ virStorageBackendLogicalRemoveDevice(def->source.devices[i].path);
ret = 0;
virStorageVolDefPtr vol)
{
int fd = -1;
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
virErrorPtr err;
struct stat sb;
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
- pool->def->target.path,
- vol->name) < 0)
+ def->target.path, vol->name) < 0)
return -1;
cmd = virCommandNewArgList(LVCREATE,
if (vol->target.backingStore)
virCommandAddArgList(cmd, "-s", vol->target.backingStore->path, NULL);
else
- virCommandAddArg(cmd, pool->def->source.name);
+ virCommandAddArg(cmd, def->source.name);
if (virCommandRun(cmd, NULL) < 0)
goto error;