diff --git a/ChangeLog b/ChangeLog index ab6314ba3b7d351cd07d60f71d1ce289a622d489..0e96c44fbe0fe4ebd30ab94961a9c2cf649eb621 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 bd973bc0589e0b989079222b6788da584c585a47..f6b22b6b3a5ee1cf545969de16592fa65ec1d411 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 8d1b1893784c62e1247db1a4ce4d2463f12a4826..62c353a53e6134811da991b7b8011628ac4dccb8 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 f782cfd6e280b2b67406d316fb34f4f1b6f962a4..3f2fcbcd956a266828205c67756a554ea18d9269 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 b501d2c7703b9efd2a0db31a7af6e029e8a48101..63511ec73065dd7154f34a616ca9fb55f877907e 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 05344f6351d20efc39843252d9bf1312011d9e5c..3fae468244f1f466c15a6b5fbc1ee0b88665dd9a 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 aa3350753039ec015ba29d9a34101f28efcd9f0e..309c35682f9d56c61a52a9e2536ae3d4fde770c6 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 51376143cfaf782bf0a4c49c062d873ca086b8c2..4944296f149f9231990cdc15f7eff4e2b2bafaac 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 4470f557cf9ce7b059c262150f94a23e842cd5c2..b7ca853c2974975a274e19826b901b77d0b60717 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 83b15d8574ef5dc7acd5a12d06b0a899c6fc60f9..60a75586b5efcfc1ea705035d741b40629176f5d 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 dd073a2f5f06d7c162803012b09a9b1f2c2a68ed..54bca2a43f88405a2a0d0f60fd7544a607a16c96 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 5ef3ad0cf332d3ff59e9711378d7d2e63e4f84ec..57fbbf9ac28319b9694ad561a46a74131d19f19d 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 f32deae9e0cfe49b84348f0fb62d4d0ab85640a6..b9cd55efdbb4fc0479b0c8631645a01dae28f8ed 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 b0b6d624ba04d8243384fb7901d9caac89982f3e..7da3ba4855a1a5a4e20be38029e8ccd92a12642a 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 832ec03bd44c906611dab1e6b98deffc72462a5d..69b944f8cfaee2713c294e4bd0771d5e3d8cb07a 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 2b11d4dec3c09c752940118de4d23ae13943a888..4300d2af9e05ef4561369220629ddba229351045 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