virDomainPtr domainPtr;
virDomainInfo info;
rte_spinlock_t config_spinlock;
+ int allow_query;
LIST_ENTRY(virtual_machine_info) vms_info;
};
channel_num++;
}
+ info->allow_query = vm_info->allow_query;
info->num_channels = channel_num;
info->num_vcpus = vm_info->info.nrVirtCpu;
rte_spinlock_unlock(&(vm_info->config_spinlock));
else
new_domain->status = CHANNEL_MGR_VM_ACTIVE;
+ new_domain->allow_query = 0;
rte_spinlock_init(&(new_domain->config_spinlock));
LIST_INSERT_HEAD(&vm_list_head, new_domain, vms_info);
return 0;
return 0;
}
+int
+set_query_status(char *vm_name,
+ bool allow_query)
+{
+ struct virtual_machine_info *vm_info;
+
+ vm_info = find_domain_by_name(vm_name);
+ if (vm_info == NULL) {
+ RTE_LOG(ERR, CHANNEL_MANAGER, "VM '%s' not found\n", vm_name);
+ return -1;
+ }
+ rte_spinlock_lock(&(vm_info->config_spinlock));
+ vm_info->allow_query = allow_query ? 1 : 0;
+ rte_spinlock_unlock(&(vm_info->config_spinlock));
+ return 0;
+}
+
static void
disconnect_hypervisor(void)
{
#include <linux/limits.h>
#include <sys/un.h>
#include <rte_atomic.h>
+#include <stdbool.h>
/* Maximum name length including '\0' terminator */
#define CHANNEL_MGR_MAX_NAME_LEN 64
unsigned num_vcpus; /**< number of vCPUS */
struct channel_info channels[RTE_MAX_LCORE]; /**< channel_info array */
unsigned num_channels; /**< Number of channels */
+ int allow_query; /**< is query allowed */
};
/**
*/
int set_pcpu(char *vm_name, unsigned int vcpu, unsigned int pcpu);
+/**
+ * Allow or disallow queries for specified VM.
+ * It is thread-safe.
+ *
+ * @param name
+ * Virtual Machine name to lookup.
+ *
+ * @param allow_query
+ * Query status to be set.
+ *
+ * @return
+ * - 0 on success.
+ * - Negative on error.
+ */
+int set_query_status(char *vm_name, bool allow_query);
+
/**
* Add a VM as specified by name to the Channel Manager. The name must
* correspond to a valid libvirt domain name.
},
};
+struct cmd_set_query_result {
+ cmdline_fixed_string_t set_query;
+ cmdline_fixed_string_t vm_name;
+ cmdline_fixed_string_t query_status;
+};
+
+static void
+cmd_set_query_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_query_result *res = parsed_result;
+
+ if (!strcmp(res->query_status, "enable")) {
+ if (set_query_status(res->vm_name, true) < 0)
+ cmdline_printf(cl, "Unable to allow query for VM '%s'\n",
+ res->vm_name);
+ } else if (!strcmp(res->query_status, "disable")) {
+ if (set_query_status(res->vm_name, false) < 0)
+ cmdline_printf(cl, "Unable to disallow query for VM '%s'\n",
+ res->vm_name);
+ }
+}
+
+cmdline_parse_token_string_t cmd_set_query =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_query_result,
+ set_query, "set_query");
+cmdline_parse_token_string_t cmd_set_query_vm_name =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_query_result,
+ vm_name, NULL);
+cmdline_parse_token_string_t cmd_set_query_status =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_query_result,
+ query_status, "enable#disable");
+
+cmdline_parse_inst_t cmd_set_query_set = {
+ .f = cmd_set_query_parsed,
+ .data = NULL,
+ .help_str = "set_query <vm_name> <enable|disable>, allow or disallow queries"
+ " for the specified VM",
+ .tokens = {
+ (void *)&cmd_set_query,
+ (void *)&cmd_set_query_vm_name,
+ (void *)&cmd_set_query_status,
+ NULL,
+ },
+};
+
struct cmd_channels_status_op_result {
cmdline_fixed_string_t op;
cmdline_fixed_string_t vm_name;
(cmdline_parse_inst_t *)&cmd_show_cpu_freq_set,
(cmdline_parse_inst_t *)&cmd_set_cpu_freq_set,
(cmdline_parse_inst_t *)&cmd_set_pcpu_set,
+ (cmdline_parse_inst_t *)&cmd_set_query_set,
NULL,
};