mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
parallels: add storage driver
Parallels Cloud Server has one serious discrepancy with libvirt: libvirt stores domain configuration files in one place, and storage files in other places (with the API of storage pools and storage volumes). Parallels Cloud Server stores all domain data in a single directory, for example, you may have domain with name fedora-15, which will be located in '/var/parallels/fedora-15.pvm', and it's hard disk image will be in '/var/parallels/fedora-15.pvm/harddisk1.hdd'. I've decided to create storage driver, which produces pseudo-volumes (xml files with volume description), and they will be 'converted' to real disk images after attaching to a VM. So if someone creates VM with one hard disk using virt-manager, at first virt-manager creates a new volume, and then defines a domain. We can lookup a volume by path in XML domain definition and find out location of new domain and size of its hard disk. Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
parent
e356f6100d
commit
aa296e6c29
@ -67,6 +67,7 @@ src/openvz/openvz_driver.c
|
||||
src/openvz/openvz_util.c
|
||||
src/parallels/parallels_driver.c
|
||||
src/parallels/parallels_utils.c
|
||||
src/parallels/parallels_storage.c
|
||||
src/phyp/phyp_driver.c
|
||||
src/qemu/qemu_agent.c
|
||||
src/qemu/qemu_bridge_filter.c
|
||||
|
@ -532,7 +532,8 @@ HYPERV_DRIVER_EXTRA_DIST = \
|
||||
PARALLELS_DRIVER_SOURCES = \
|
||||
parallels/parallels_driver.h \
|
||||
parallels/parallels_driver.c \
|
||||
parallels/parallels_utils.c
|
||||
parallels/parallels_utils.c \
|
||||
parallels/parallels_storage.c
|
||||
|
||||
NETWORK_DRIVER_SOURCES = \
|
||||
network/bridge_driver.h network/bridge_driver.c
|
||||
|
@ -49,10 +49,7 @@
|
||||
#include "command.h"
|
||||
#include "configmake.h"
|
||||
#include "storage_file.h"
|
||||
#include "storage_conf.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "json.h"
|
||||
#include "domain_conf.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#include "parallels_driver.h"
|
||||
@ -76,33 +73,15 @@
|
||||
virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__, \
|
||||
__FUNCTION__, __LINE__, _("Can't parse prlctl output"))
|
||||
|
||||
struct _parallelsConn {
|
||||
virMutex lock;
|
||||
virDomainObjList domains;
|
||||
virStoragePoolObjList pools;
|
||||
virCapsPtr caps;
|
||||
};
|
||||
|
||||
typedef struct _parallelsConn parallelsConn;
|
||||
typedef struct _parallelsConn *parallelsConnPtr;
|
||||
|
||||
struct parallelsDomObj {
|
||||
int id;
|
||||
char *uuid;
|
||||
char *os;
|
||||
};
|
||||
|
||||
typedef struct parallelsDomObj *parallelsDomObjPtr;
|
||||
|
||||
static int parallelsClose(virConnectPtr conn);
|
||||
|
||||
static void
|
||||
void
|
||||
parallelsDriverLock(parallelsConnPtr driver)
|
||||
{
|
||||
virMutexLock(&driver->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
parallelsDriverUnlock(parallelsConnPtr driver)
|
||||
{
|
||||
virMutexUnlock(&driver->lock);
|
||||
@ -1668,6 +1647,8 @@ parallelsRegister(void)
|
||||
|
||||
if (virRegisterDriver(¶llelsDriver) < 0)
|
||||
return -1;
|
||||
if (parallelsStorageRegister())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1393
src/parallels/parallels_storage.c
Normal file
1393
src/parallels/parallels_storage.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -125,3 +125,25 @@ parallelsCmdRun(const char *binary, ...)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return new file path in malloced string created by
|
||||
* concatenating first and second function arguments.
|
||||
*/
|
||||
char *
|
||||
parallelsAddFileExt(const char *path, const char *ext)
|
||||
{
|
||||
char *new_path = NULL;
|
||||
size_t len = strlen(path) + strlen(ext) + 1;
|
||||
|
||||
if (VIR_ALLOC_N(new_path, len) < 0) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!virStrcpy(new_path, path, len))
|
||||
return NULL;
|
||||
strcat(new_path, ext);
|
||||
|
||||
return new_path;
|
||||
}
|
||||
|
@ -23,11 +23,42 @@
|
||||
#ifndef PARALLELS_UTILS_H
|
||||
# define PARALLELS_UTILS_H
|
||||
|
||||
# include "driver.h"
|
||||
# include "util/threads.h"
|
||||
# include "conf/domain_conf.h"
|
||||
# include "conf/storage_conf.h"
|
||||
# include "conf/domain_event.h"
|
||||
# include "json.h"
|
||||
|
||||
struct _parallelsConn {
|
||||
virMutex lock;
|
||||
virDomainObjList domains;
|
||||
virStoragePoolObjList pools;
|
||||
virCapsPtr caps;
|
||||
virDomainEventStatePtr domainEventState;
|
||||
};
|
||||
|
||||
typedef struct _parallelsConn parallelsConn;
|
||||
typedef struct _parallelsConn *parallelsConnPtr;
|
||||
|
||||
struct parallelsDomObj {
|
||||
int id;
|
||||
char *uuid;
|
||||
char *os;
|
||||
};
|
||||
|
||||
typedef struct parallelsDomObj *parallelsDomObjPtr;
|
||||
|
||||
int parallelsStorageRegister(void);
|
||||
|
||||
virJSONValuePtr parallelsParseOutput(const char *binary, ...)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
|
||||
char * parallelsGetOutput(const char *binary, ...)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
|
||||
int parallelsCmdRun(const char *binary, ...)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
|
||||
char * parallelsAddFileExt(const char *path, const char *ext);
|
||||
void parallelsDriverLock(parallelsConnPtr driver);
|
||||
void parallelsDriverUnlock(parallelsConnPtr driver);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user