From 19e21d867253df6e49d48bf6b8530402c8eb03ed Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 21 Aug 2007 09:03:55 +0000 Subject: [PATCH] Tue Aug 21 09:56:00 BST 2007 Richard W.M. Jones * qemud/remote.c, qemud/remote_protocol.x, src/driver.h, src/internal.h, src/libvirt.c, src/libvirt_sym.version, src/qemu_driver.c, src/remote_internal.c, src/test.c: Add a private interface so that libvirt.c coordination functions can detect the availability of features in underlying drivers, using the VIR_DRV_SUPPORTS_FEATURE macro. --- ChangeLog | 10 ++++++++++ docs/hvsupport.html | 6 +++--- qemud/remote.c | 12 +++++++++++ qemud/remote_dispatch_localvars.h | 4 +++- qemud/remote_dispatch_proc_switch.h | 9 +++++++++ qemud/remote_dispatch_prototypes.h | 1 + qemud/remote_protocol.c | 18 +++++++++++++++++ qemud/remote_protocol.h | 15 ++++++++++++++ qemud/remote_protocol.x | 11 +++++++++- src/driver.h | 31 +++++++++++++++++++++++++++++ src/internal.h | 2 ++ src/libvirt.c | 14 +++++++++++++ src/libvirt_sym.version | 2 ++ src/qemu_driver.c | 1 + src/remote_internal.c | 22 ++++++++++++++++++++ src/test.c | 1 + 16 files changed, 154 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab6314ba3b..0e96c44fbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Aug 21 09:56:00 BST 2007 Richard W.M. Jones + + * qemud/remote.c, qemud/remote_protocol.x, src/driver.h, + src/internal.h, src/libvirt.c, src/libvirt_sym.version, + src/qemu_driver.c, src/remote_internal.c, src/test.c: + Add a private interface so that libvirt.c coordination + functions can detect the availability of features in + underlying drivers, using the VIR_DRV_SUPPORTS_FEATURE + macro. + Tue Aug 21 09:45:00 BST 2007 Richard W.M. Jones * src/xend_internal.c: Return the interface device name as diff --git a/docs/hvsupport.html b/docs/hvsupport.html index bd973bc058..f6b22b6b3a 100644 --- a/docs/hvsupport.html +++ b/docs/hvsupport.html @@ -5,7 +5,7 @@ This page documents which libvirt calls work on which hypervisors.

This information changes frequently. This page was last checked or -updated on 2007-06-29. +updated on 2007-08-20.

Domain functions

x = not supported; empty cell means no information

@@ -259,7 +259,7 @@ updated on 2007-06-29. - + @@ -271,7 +271,7 @@ updated on 2007-06-29. - + diff --git a/qemud/remote.c b/qemud/remote.c index 8d1b189378..62c353a53e 100644 --- a/qemud/remote.c +++ b/qemud/remote.c @@ -417,6 +417,18 @@ remoteDispatchClose (struct qemud_client *client, remote_message_header *req, return rv; } +static int +remoteDispatchSupportsFeature (struct qemud_client *client, remote_message_header *req, + remote_supports_feature_args *args, remote_supports_feature_ret *ret) +{ + CHECK_CONN(client); + + ret->supported = __virDrvSupportsFeature (client->conn, args->feature); + if (ret->supported == -1) return -1; + + return 0; +} + static int remoteDispatchGetType (struct qemud_client *client, remote_message_header *req, void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret) diff --git a/qemud/remote_dispatch_localvars.h b/qemud/remote_dispatch_localvars.h index f782cfd6e2..3f2fcbcd95 100644 --- a/qemud/remote_dispatch_localvars.h +++ b/qemud/remote_dispatch_localvars.h @@ -20,9 +20,9 @@ remote_domain_get_os_type_ret lv_remote_domain_get_os_type_ret; remote_domain_get_autostart_args lv_remote_domain_get_autostart_args; remote_domain_get_autostart_ret lv_remote_domain_get_autostart_ret; remote_domain_set_vcpus_args lv_remote_domain_set_vcpus_args; -remote_get_hostname_ret lv_remote_get_hostname_ret; remote_domain_get_scheduler_type_args lv_remote_domain_get_scheduler_type_args; remote_domain_get_scheduler_type_ret lv_remote_domain_get_scheduler_type_ret; +remote_get_hostname_ret lv_remote_get_hostname_ret; remote_network_undefine_args lv_remote_network_undefine_args; remote_domain_create_args lv_remote_domain_create_args; remote_domain_suspend_args lv_remote_domain_suspend_args; @@ -67,6 +67,8 @@ remote_domain_get_info_args lv_remote_domain_get_info_args; remote_domain_get_info_ret lv_remote_domain_get_info_ret; remote_network_create_args lv_remote_network_create_args; remote_num_of_defined_networks_ret lv_remote_num_of_defined_networks_ret; +remote_supports_feature_args lv_remote_supports_feature_args; +remote_supports_feature_ret lv_remote_supports_feature_ret; remote_domain_lookup_by_name_args lv_remote_domain_lookup_by_name_args; remote_domain_lookup_by_name_ret lv_remote_domain_lookup_by_name_ret; remote_network_lookup_by_uuid_args lv_remote_network_lookup_by_uuid_args; diff --git a/qemud/remote_dispatch_proc_switch.h b/qemud/remote_dispatch_proc_switch.h index b501d2c770..63511ec730 100644 --- a/qemud/remote_dispatch_proc_switch.h +++ b/qemud/remote_dispatch_proc_switch.h @@ -431,3 +431,12 @@ case REMOTE_PROC_OPEN: args = (char *) &lv_remote_open_args; memset (&lv_remote_open_args, 0, sizeof lv_remote_open_args); break; +case REMOTE_PROC_SUPPORTS_FEATURE: + fn = (dispatch_fn) remoteDispatchSupportsFeature; + args_filter = (xdrproc_t) xdr_remote_supports_feature_args; + args = (char *) &lv_remote_supports_feature_args; + memset (&lv_remote_supports_feature_args, 0, sizeof lv_remote_supports_feature_args); + ret_filter = (xdrproc_t) xdr_remote_supports_feature_ret; + ret = (char *) &lv_remote_supports_feature_ret; + memset (&lv_remote_supports_feature_ret, 0, sizeof lv_remote_supports_feature_ret); + break; diff --git a/qemud/remote_dispatch_prototypes.h b/qemud/remote_dispatch_prototypes.h index 05344f6351..3fae468244 100644 --- a/qemud/remote_dispatch_prototypes.h +++ b/qemud/remote_dispatch_prototypes.h @@ -61,3 +61,4 @@ static int remoteDispatchNumOfDefinedNetworks (struct qemud_client *client, remo static int remoteDispatchNumOfDomains (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_domains_ret *ret); static int remoteDispatchNumOfNetworks (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_networks_ret *ret); static int remoteDispatchOpen (struct qemud_client *client, remote_message_header *req, remote_open_args *args, void *ret); +static int remoteDispatchSupportsFeature (struct qemud_client *client, remote_message_header *req, remote_supports_feature_args *args, remote_supports_feature_ret *ret); diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c index aa33507530..309c35682f 100644 --- a/qemud/remote_protocol.c +++ b/qemud/remote_protocol.c @@ -177,6 +177,24 @@ xdr_remote_open_args (XDR *xdrs, remote_open_args *objp) return TRUE; } +bool_t +xdr_remote_supports_feature_args (XDR *xdrs, remote_supports_feature_args *objp) +{ + + if (!xdr_int (xdrs, &objp->feature)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_supports_feature_ret (XDR *xdrs, remote_supports_feature_ret *objp) +{ + + if (!xdr_int (xdrs, &objp->supported)) + return FALSE; + return TRUE; +} + bool_t xdr_remote_get_type_ret (XDR *xdrs, remote_get_type_ret *objp) { diff --git a/qemud/remote_protocol.h b/qemud/remote_protocol.h index 51376143cf..4944296f14 100644 --- a/qemud/remote_protocol.h +++ b/qemud/remote_protocol.h @@ -95,6 +95,16 @@ struct remote_open_args { }; typedef struct remote_open_args remote_open_args; +struct remote_supports_feature_args { + int feature; +}; +typedef struct remote_supports_feature_args remote_supports_feature_args; + +struct remote_supports_feature_ret { + int supported; +}; +typedef struct remote_supports_feature_ret remote_supports_feature_ret; + struct remote_get_type_ret { remote_nonnull_string type; }; @@ -632,6 +642,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS = 57, REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS = 58, REMOTE_PROC_GET_HOSTNAME = 59, + REMOTE_PROC_SUPPORTS_FEATURE = 60, }; typedef enum remote_procedure remote_procedure; @@ -673,6 +684,8 @@ extern bool_t xdr_remote_vcpu_info (XDR *, remote_vcpu_info*); extern bool_t xdr_remote_sched_param_value (XDR *, remote_sched_param_value*); extern bool_t xdr_remote_sched_param (XDR *, remote_sched_param*); extern bool_t xdr_remote_open_args (XDR *, remote_open_args*); +extern bool_t xdr_remote_supports_feature_args (XDR *, remote_supports_feature_args*); +extern bool_t xdr_remote_supports_feature_ret (XDR *, remote_supports_feature_ret*); extern bool_t xdr_remote_get_type_ret (XDR *, remote_get_type_ret*); extern bool_t xdr_remote_get_version_ret (XDR *, remote_get_version_ret*); extern bool_t xdr_remote_get_hostname_ret (XDR *, remote_get_hostname_ret*); @@ -774,6 +787,8 @@ extern bool_t xdr_remote_vcpu_info (); extern bool_t xdr_remote_sched_param_value (); extern bool_t xdr_remote_sched_param (); extern bool_t xdr_remote_open_args (); +extern bool_t xdr_remote_supports_feature_args (); +extern bool_t xdr_remote_supports_feature_ret (); extern bool_t xdr_remote_get_type_ret (); extern bool_t xdr_remote_get_version_ret (); extern bool_t xdr_remote_get_hostname_ret (); diff --git a/qemud/remote_protocol.x b/qemud/remote_protocol.x index 4470f557cf..b7ca853c29 100644 --- a/qemud/remote_protocol.x +++ b/qemud/remote_protocol.x @@ -170,6 +170,14 @@ struct remote_open_args { int flags; }; +struct remote_supports_feature_args { + int feature; +}; + +struct remote_supports_feature_ret { + int supported; +}; + struct remote_get_type_ret { remote_nonnull_string type; }; @@ -610,7 +618,8 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_SCHEDULER_TYPE = 56, REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS = 57, REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS = 58, - REMOTE_PROC_GET_HOSTNAME = 59 + REMOTE_PROC_GET_HOSTNAME = 59, + REMOTE_PROC_SUPPORTS_FEATURE = 60 }; /* Custom RPC structure. */ diff --git a/src/driver.h b/src/driver.h index 83b15d8574..60a75586b5 100644 --- a/src/driver.h +++ b/src/driver.h @@ -44,12 +44,42 @@ typedef enum { VIR_DRV_OPEN_ERROR = -2, } virDrvOpenStatus; +/* Feature detection. This is a libvirt-private interface for determining + * what features are supported by the driver. + * + * The remote driver passes features through to the real driver at the + * remote end unmodified, except if you query a VIR_DRV_FEATURE_REMOTE* + * feature. + */ + /* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/ + * domainMigratePerform/domainMigrateFinish. + */ +#define VIR_DRV_FEATURE_MIGRATION_V1 1 + + /* Driver is not local. */ +#define VIR_DRV_FEATURE_REMOTE 2 + +/* Internal feature-detection macro. Don't call drv->supports_feature + * directly, because it may be NULL, use this macro instead. + * + * Note that you must check for errors. + * + * Returns: + * >= 1 Feature is supported. + * 0 Feature is not supported. + * -1 Error. + */ +#define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature) \ + ((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0) + typedef virDrvOpenStatus (*virDrvOpen) (virConnectPtr conn, const char *name, int flags); typedef int (*virDrvClose) (virConnectPtr conn); +typedef int + (*virDrvSupportsFeature) (virConnectPtr conn, int feature); typedef const char * (*virDrvGetType) (virConnectPtr conn); typedef int @@ -202,6 +232,7 @@ struct _virDriver { unsigned long ver; /* the version of the backend */ virDrvOpen open; virDrvClose close; + virDrvSupportsFeature supports_feature; virDrvGetType type; virDrvGetVersion version; virDrvGetHostname getHostname; diff --git a/src/internal.h b/src/internal.h index dd073a2f5f..54bca2a43f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -229,6 +229,8 @@ int __virStateActive(void); #define virStateReload() __virStateReload() #define virStateActive() __virStateActive() +int __virDrvSupportsFeature (virConnectPtr conn, int feature); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/libvirt.c b/src/libvirt.c index 5ef3ad0cf3..57fbbf9ac2 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -540,6 +540,20 @@ virConnectClose(virConnectPtr conn) return (0); } +/* Not for public use. This function is part of the internal + * implementation of driver features in the remote case. + */ +int +__virDrvSupportsFeature (virConnectPtr conn, int feature) +{ + DEBUG("conn=%p, feature=%d", conn, feature); + + if (!VIR_IS_CONNECT(conn)) + return (-1); + + return VIR_DRV_SUPPORTS_FEATURE (conn->driver, conn, feature); +} + /** * virConnectGetType: * @conn: pointer to the hypervisor connection diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version index f32deae9e0..b9cd55efdb 100644 --- a/src/libvirt_sym.version +++ b/src/libvirt_sym.version @@ -116,5 +116,7 @@ __virStateReload; __virStateActive; + __virDrvSupportsFeature; + local: *; }; diff --git a/src/qemu_driver.c b/src/qemu_driver.c index b0b6d624ba..7da3ba4855 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2618,6 +2618,7 @@ static virDriver qemuDriver = { LIBVIR_VERSION_NUMBER, qemudOpen, /* open */ qemudClose, /* close */ + NULL, /* supports_feature */ qemudGetType, /* type */ qemudGetVersion, /* version */ NULL, /* hostname */ diff --git a/src/remote_internal.c b/src/remote_internal.c index 832ec03bd4..69b944f8cf 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -1195,6 +1195,27 @@ remoteClose (virConnectPtr conn) return ret; } +static int +remoteSupportsFeature (virConnectPtr conn, int feature) +{ + remote_supports_feature_args args; + remote_supports_feature_ret ret; + GET_PRIVATE (conn, -1); + + /* VIR_DRV_FEATURE_REMOTE* features are handled directly. */ + if (feature == VIR_DRV_FEATURE_REMOTE) return 1; + + args.feature = feature; + + memset (&ret, 0, sizeof ret); + if (call (conn, priv, 0, REMOTE_PROC_SUPPORTS_FEATURE, + (xdrproc_t) xdr_remote_supports_feature_args, (char *) &args, + (xdrproc_t) xdr_remote_supports_feature_ret, (char *) &ret) == -1) + return -1; + + return ret.supported; +} + /* Unfortunately this function is defined to return a static string. * Since the remote end always answers with the same type (for a * single connection anyway) we cache the type in the connection's @@ -2898,6 +2919,7 @@ static virDriver driver = { .ver = REMOTE_PROTOCOL_VERSION, .open = remoteOpen, .close = remoteClose, + .supports_feature = remoteSupportsFeature, .type = remoteType, .version = remoteVersion, .getHostname = remoteGetHostname, diff --git a/src/test.c b/src/test.c index 2b11d4dec3..4300d2af9e 100644 --- a/src/test.c +++ b/src/test.c @@ -1920,6 +1920,7 @@ static virDriver testDriver = { LIBVIR_VERSION_NUMBER, testOpen, /* open */ testClose, /* close */ + NULL, /* supports_feature */ NULL, /* type */ testGetVersion, /* version */ testGetHostname, /* hostname */
Function Since Xen All All x x ≥ 0.3.2 ≥ 0.3.0
virDomainResume All All All x x ≥ 0.3.2 ≥ 0.3.0
virDomainSetAutostart 0.2.1