mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Implement disk volume deleting.
This commit is contained in:
parent
a82bd0784b
commit
bf26cd8ecb
@ -1,3 +1,7 @@
|
|||||||
|
Tue Sep 16 12:43:00 EST 2008 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
|
* src/storack_backend_disk.c: Implement disk volume delete
|
||||||
|
|
||||||
Tue Sep 9 09:50:00 EST 2008 Cole Robinson <crobinso@redhat.com>
|
Tue Sep 9 09:50:00 EST 2008 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
* src/xend_internal.c: fix reading vncdisplay from xend domain
|
* src/xend_internal.c: fix reading vncdisplay from xend domain
|
||||||
|
@ -22,12 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "storage_backend_disk.h"
|
#include "storage_backend_disk.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__)
|
||||||
|
#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
VIR_STORAGE_POOL_DISK_DOS = 0,
|
VIR_STORAGE_POOL_DISK_DOS = 0,
|
||||||
VIR_STORAGE_POOL_DISK_DVH,
|
VIR_STORAGE_POOL_DISK_DVH,
|
||||||
@ -419,13 +423,6 @@ virStorageBackendDiskBuildPool(virConnectPtr conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
virStorageBackendDiskDeleteVol(virConnectPtr conn,
|
|
||||||
virStoragePoolObjPtr pool,
|
|
||||||
virStorageVolDefPtr vol,
|
|
||||||
unsigned int flags);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendDiskCreateVol(virConnectPtr conn,
|
virStorageBackendDiskCreateVol(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool,
|
virStoragePoolObjPtr pool,
|
||||||
@ -489,14 +486,61 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendDiskDeleteVol(virConnectPtr conn,
|
virStorageBackendDiskDeleteVol(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
|
virStoragePoolObjPtr pool,
|
||||||
virStorageVolDefPtr vol ATTRIBUTE_UNUSED,
|
virStorageVolDefPtr vol,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
/* delete a partition */
|
char *part_num = NULL;
|
||||||
virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
|
int n;
|
||||||
_("Disk pools are not yet supported"));
|
char devpath[PATH_MAX];
|
||||||
return -1;
|
char *devname, *srcname;
|
||||||
|
|
||||||
|
if ((n = readlink(vol->target.path, devpath, sizeof(devpath))) < 0 &&
|
||||||
|
errno != EINVAL) {
|
||||||
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Couldn't read volume target path '%s'. %s"),
|
||||||
|
vol->target.path, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
} else if (n <= 0) {
|
||||||
|
strncpy(devpath, vol->target.path, PATH_MAX);
|
||||||
|
} else {
|
||||||
|
devpath[n] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
devname = basename(devpath);
|
||||||
|
srcname = basename(pool->def->source.devices[0].path);
|
||||||
|
DEBUG("devname=%s, srcname=%s", devname, srcname);
|
||||||
|
|
||||||
|
if (!STRPREFIX(devname, srcname)) {
|
||||||
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Volume path '%s' did not start with parent "
|
||||||
|
"pool source device name."), devname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
part_num = devname + strlen(srcname);
|
||||||
|
|
||||||
|
if (!part_num) {
|
||||||
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("cannot parse partition number from target "
|
||||||
|
"'%s'"), devname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* eg parted /dev/sda rm 2 */
|
||||||
|
const char *prog[] = {
|
||||||
|
PARTED,
|
||||||
|
pool->def->source.devices[0].path,
|
||||||
|
"rm",
|
||||||
|
"--script",
|
||||||
|
part_num,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (virRun(conn, prog, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user