vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- virtio_pci_create_if_args_t args;
+ virtio_pci_create_if_args_t args = {};
u64 feature_mask = (u64) ~ (0ULL);
u32 buffering_size = 0;
u32 txq_size = 0;
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- memset (&args, 0, sizeof (args));
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vlib_pci_addr, &args.addr))
;
+ else if (unformat (line_input, "if-name %s", &args.if_name))
+ ;
else if (unformat (line_input, "feature-mask 0x%llx", &feature_mask))
args.features = feature_mask;
else if (unformat (line_input, "tx-queue-size %u", &txq_size))
virtio_pci_create_if (vm, &args);
+ vec_free (args.if_name);
+
return args.error;
}
VLIB_CLI_COMMAND (virtio_pci_create_command, static) = {
.path = "create interface virtio",
- .short_help = "create interface virtio <pci-address> "
+ .short_help = "create interface virtio <pci-address> [if-name <if-name>] "
"[feature-mask <hex-mask>] [tx-queue-size <size>] "
"[gso-enabled] [csum-enabled] [rss-enabled] "
"[buffering [size <buffering-szie>]] [packed] [bind [force]]",
}
}
- pool_get (vim->interfaces, vif);
+ pool_get_zero (vim->interfaces, vif);
vif->dev_instance = vif - vim->interfaces;
vif->per_interface_next_index = ~0;
vif->pci_addr.as_u32 = args->addr;
vif->numa_node = vlib_pci_get_numa_node (vm, h);
vif->type = VIRTIO_IF_TYPE_PCI;
+ if (args->if_name)
+ CLIB_SWAP (args->if_name, vif->initial_if_name);
+
if ((error = vlib_pci_bus_master_enable (vm, h)))
{
virtio_log_error (vif, "error encountered on pci bus master enable");
vec_free (vif->cxq_vring);
clib_error_free (vif->error);
- memset (vif, 0, sizeof (*vif));
+ vec_free (vif->initial_if_name);
pool_put (vim->interfaces, vif);
return 0;