remote: add support for nwfilter binding objects

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2018-05-09 17:18:58 +01:00
parent 099812f59d
commit ede0924eb4
5 changed files with 173 additions and 7 deletions

View File

@ -90,6 +90,7 @@ static virStoragePoolPtr get_nonnull_storage_pool(virConnectPtr conn, remote_non
static virStorageVolPtr get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol);
static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret);
static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
static virNWFilterBindingPtr get_nonnull_nwfilter_binding(virConnectPtr conn, remote_nonnull_nwfilter_binding binding);
static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot);
static virNodeDevicePtr get_nonnull_node_device(virConnectPtr conn, remote_nonnull_node_device dev);
static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
@ -100,6 +101,7 @@ static void make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virSto
static void make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
static void make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
static void make_nonnull_nwfilter(remote_nonnull_nwfilter *net_dst, virNWFilterPtr nwfilter_src);
static void make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst, virNWFilterBindingPtr binding_src);
static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
static int
@ -7087,6 +7089,12 @@ get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
return virGetNWFilter(conn, nwfilter.name, BAD_CAST nwfilter.uuid);
}
static virNWFilterBindingPtr
get_nonnull_nwfilter_binding(virConnectPtr conn, remote_nonnull_nwfilter_binding binding)
{
return virGetNWFilterBinding(conn, binding.portdev, binding.filtername);
}
static virDomainSnapshotPtr
get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot)
{
@ -7159,6 +7167,13 @@ make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfi
memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
}
static void
make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst, virNWFilterBindingPtr binding_src)
{
ignore_value(VIR_STRDUP_QUIET(binding_dst->portdev, binding_src->portdev));
ignore_value(VIR_STRDUP_QUIET(binding_dst->filtername, binding_src->filtername));
}
static void
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
{

View File

@ -141,6 +141,7 @@ static int remoteAuthPolkit(virConnectPtr conn, struct private_data *priv,
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
static virNWFilterBindingPtr get_nonnull_nwfilter_binding(virConnectPtr conn, remote_nonnull_nwfilter_binding binding);
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
static virStoragePoolPtr get_nonnull_storage_pool(virConnectPtr conn, remote_nonnull_storage_pool pool);
static virStorageVolPtr get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol);
@ -156,6 +157,7 @@ static void
make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
static void make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
static void make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src);
static void make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst, virNWFilterBindingPtr binding_src);
static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
/*----------------------------------------------------------------------*/
@ -8206,6 +8208,12 @@ get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
return virGetNWFilter(conn, nwfilter.name, BAD_CAST nwfilter.uuid);
}
static virNWFilterBindingPtr
get_nonnull_nwfilter_binding(virConnectPtr conn, remote_nonnull_nwfilter_binding binding)
{
return virGetNWFilterBinding(conn, binding.portdev, binding.filtername);
}
static virDomainSnapshotPtr
get_nonnull_domain_snapshot(virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
{
@ -8273,6 +8281,13 @@ make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfi
memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
}
static void
make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst, virNWFilterBindingPtr binding_src)
{
binding_dst->portdev = binding_src->portdev;
binding_dst->filtername = binding_src->filtername;
}
static void
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
{
@ -8656,6 +8671,11 @@ static virNWFilterDriver nwfilter_driver = {
.connectNumOfNWFilters = remoteConnectNumOfNWFilters, /* 0.8.0 */
.connectListNWFilters = remoteConnectListNWFilters, /* 0.8.0 */
.connectListAllNWFilters = remoteConnectListAllNWFilters, /* 0.10.2 */
.connectListAllNWFilterBindings = remoteConnectListAllNWFilterBindings, /* 4.5.0 */
.nwfilterBindingLookupByPortDev = remoteNWFilterBindingLookupByPortDev, /* 4.5.0 */
.nwfilterBindingCreateXML = remoteNWFilterBindingCreateXML, /* 4.5.0 */
.nwfilterBindingDelete = remoteNWFilterBindingDelete, /* 4.5.0 */
.nwfilterBindingGetXMLDesc = remoteNWFilterBindingGetXMLDesc, /* 4.5.0 */
};
static virConnectDriver connect_driver = {

View File

@ -94,6 +94,9 @@ const REMOTE_NODE_DEVICE_CAPS_LIST_MAX = 65536;
/* Upper limit on lists of network filters. */
const REMOTE_NWFILTER_LIST_MAX = 16384;
/* Upper limit on lists of network filter bindings. */
const REMOTE_NWFILTER_BINDING_LIST_MAX = 16384;
/* Upper limit on list of scheduler parameters. */
const REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX = 16;
@ -281,6 +284,12 @@ struct remote_nonnull_nwfilter {
remote_uuid uuid;
};
/* A network filter binding which may not be NULL. */
struct remote_nonnull_nwfilter_binding {
remote_nonnull_string portdev;
remote_nonnull_string filtername;
};
/* An interface which may not be NULL. */
struct remote_nonnull_interface {
remote_nonnull_string name;
@ -322,6 +331,7 @@ struct remote_nonnull_domain_snapshot {
typedef remote_nonnull_domain *remote_domain;
typedef remote_nonnull_network *remote_network;
typedef remote_nonnull_nwfilter *remote_nwfilter;
typedef remote_nonnull_nwfilter_binding *remote_nwfilter_binding;
typedef remote_nonnull_storage_pool *remote_storage_pool;
typedef remote_nonnull_storage_vol *remote_storage_vol;
typedef remote_nonnull_node_device *remote_node_device;
@ -3505,6 +3515,48 @@ struct remote_domain_get_launch_security_info_ret {
remote_typed_param params<REMOTE_DOMAIN_LAUNCH_SECURITY_INFO_PARAMS_MAX>;
};
/* nwfilter binding */
struct remote_nwfilter_binding_lookup_by_port_dev_args {
remote_nonnull_string name;
};
struct remote_nwfilter_binding_lookup_by_port_dev_ret {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_create_xml_args {
remote_nonnull_string xml;
unsigned int flags;
};
struct remote_nwfilter_binding_create_xml_ret {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_delete_args {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_get_xml_desc_args {
remote_nonnull_nwfilter_binding nwfilter;
unsigned int flags;
};
struct remote_nwfilter_binding_get_xml_desc_ret {
remote_nonnull_string xml;
};
struct remote_connect_list_all_nwfilter_bindings_args {
int need_results;
unsigned int flags;
};
struct remote_connect_list_all_nwfilter_bindings_ret { /* insert@1 */
remote_nonnull_nwfilter_binding bindings<REMOTE_NWFILTER_BINDING_LIST_MAX>;
unsigned int ret;
};
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@ -6224,5 +6276,41 @@ enum remote_procedure {
* @generate: none
* @acl: domain:read
*/
REMOTE_PROC_DOMAIN_GET_LAUNCH_SECURITY_INFO = 396
REMOTE_PROC_DOMAIN_GET_LAUNCH_SECURITY_INFO = 396,
/**
* @generate: both
* @priority: high
* @acl: nwfilter_binding:getattr
*/
REMOTE_PROC_NWFILTER_BINDING_LOOKUP_BY_PORT_DEV = 397,
/**
* @generate: both
* @priority: high
* @acl: nwfilter_binding:read
*/
REMOTE_PROC_NWFILTER_BINDING_GET_XML_DESC = 398,
/**
* @generate: both
* @priority: high
* @acl: nwfilter_binding:create
*/
REMOTE_PROC_NWFILTER_BINDING_CREATE_XML = 399,
/**
* @generate: both
* @priority: high
* @acl: nwfilter_binding:delete
*/
REMOTE_PROC_NWFILTER_BINDING_DELETE = 400,
/**
* @generate: both
* @priority: high
* @acl: connect:search_nwfilter_bindings
* @aclfilter: nwfilter_binding:getattr
*/
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS = 401
};

View File

@ -21,6 +21,10 @@ struct remote_nonnull_nwfilter {
remote_nonnull_string name;
remote_uuid uuid;
};
struct remote_nonnull_nwfilter_binding {
remote_nonnull_string portdev;
remote_nonnull_string filtername;
};
struct remote_nonnull_interface {
remote_nonnull_string name;
remote_nonnull_string mac;
@ -2928,6 +2932,40 @@ struct remote_domain_get_launch_security_info_ret {
remote_typed_param * params_val;
} params;
};
struct remote_nwfilter_binding_lookup_by_port_dev_args {
remote_nonnull_string name;
};
struct remote_nwfilter_binding_lookup_by_port_dev_ret {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_create_xml_args {
remote_nonnull_string xml;
u_int flags;
};
struct remote_nwfilter_binding_create_xml_ret {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_delete_args {
remote_nonnull_nwfilter_binding nwfilter;
};
struct remote_nwfilter_binding_get_xml_desc_args {
remote_nonnull_nwfilter_binding nwfilter;
u_int flags;
};
struct remote_nwfilter_binding_get_xml_desc_ret {
remote_nonnull_string xml;
};
struct remote_connect_list_all_nwfilter_bindings_args {
int need_results;
u_int flags;
};
struct remote_connect_list_all_nwfilter_bindings_ret {
struct {
u_int bindings_len;
remote_nonnull_nwfilter_binding * bindings_val;
} bindings;
u_int ret;
};
enum remote_procedure {
REMOTE_PROC_CONNECT_OPEN = 1,
REMOTE_PROC_CONNECT_CLOSE = 2,
@ -3325,4 +3363,9 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU = 394,
REMOTE_PROC_NODE_GET_SEV_INFO = 395,
REMOTE_PROC_DOMAIN_GET_LAUNCH_SECURITY_INFO = 396,
REMOTE_PROC_NWFILTER_BINDING_LOOKUP_BY_PORT_DEV = 397,
REMOTE_PROC_NWFILTER_BINDING_GET_XML_DESC = 398,
REMOTE_PROC_NWFILTER_BINDING_CREATE_XML = 399,
REMOTE_PROC_NWFILTER_BINDING_DELETE = 400,
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS = 401,
};

View File

@ -557,7 +557,7 @@ elsif ($mode eq "server") {
if ($args_member =~ m/^remote_nonnull_string name;/ and $has_node_device) {
# ignore the name arg for node devices
next
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter) (\S+);/) {
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter|nwfilter_binding) (\S+);/) {
my $type_name = name_to_TypeName($1);
push(@vars_list, "vir${type_name}Ptr $2 = NULL");
@ -722,7 +722,7 @@ elsif ($mode eq "server") {
if (!$modern_ret_as_list) {
push(@ret_list, "ret->$3 = tmp.$3;");
}
} elsif ($ret_member =~ m/(?:admin|remote)_nonnull_(secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|domain_snapshot|domain|server|client) (\S+)<(\S+)>;/) {
} elsif ($ret_member =~ m/(?:admin|remote)_nonnull_(secret|nwfilter|nwfilter_binding|node_device|interface|network|storage_vol|storage_pool|domain_snapshot|domain|server|client) (\S+)<(\S+)>;/) {
$modern_ret_struct_name = $1;
$single_ret_list_error_msg_type = $1;
$single_ret_list_name = $2;
@ -780,7 +780,7 @@ elsif ($mode eq "server") {
$single_ret_var = $1;
$single_ret_by_ref = 0;
$single_ret_check = " == NULL";
} elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_snapshot) (\S+);/) {
} elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|nwfilter_binding|domain_snapshot) (\S+);/) {
my $type_name = name_to_TypeName($1);
if ($call->{ProcName} eq "DomainCreateWithFlags") {
@ -1325,7 +1325,7 @@ elsif ($mode eq "client") {
$priv_src = "dev->conn";
push(@args_list, "virNodeDevicePtr dev");
push(@setters_list, "args.name = dev->name;");
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter|domain_snapshot) (\S+);/) {
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter|nwfilter_binding|domain_snapshot) (\S+);/) {
my $name = $1;
my $arg_name = $2;
my $type_name = name_to_TypeName($name);
@ -1518,7 +1518,7 @@ elsif ($mode eq "client") {
}
push(@ret_list, "memcpy(result->$3, ret.$3, sizeof(result->$3));");
} elsif ($ret_member =~ m/(?:admin|remote)_nonnull_(secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|domain_snapshot|domain|server|client) (\S+)<(\S+)>;/) {
} elsif ($ret_member =~ m/(?:admin|remote)_nonnull_(secret|nwfilter|nwfilter_binding|node_device|interface|network|storage_vol|storage_pool|domain_snapshot|domain|server|client) (\S+)<(\S+)>;/) {
my $proc_name = name_to_TypeName($1);
if ($structprefix eq "admin") {
@ -1571,7 +1571,7 @@ elsif ($mode eq "client") {
push(@ret_list, "VIR_FREE(ret.$1);");
$single_ret_var = "char *rv = NULL";
$single_ret_type = "char *";
} elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|node_device|interface|secret|nwfilter|domain_snapshot) (\S+);/) {
} elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|node_device|interface|secret|nwfilter|nwfilter_binding|domain_snapshot) (\S+);/) {
my $name = $1;
my $arg_name = $2;
my $type_name = name_to_TypeName($name);