summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-11-21 12:52:22 +0000
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-24 09:35:15 +0000
commitece983dd45f54ad059a619408f4cf0d11e2e8988 (patch)
tree2056636626f303088bb95d383c92cffcf2d57c73
parent7a91b46e03f8d67d2669050fdb890ef11c31de79 (diff)
vhost: CLI delete interface by name
Adds interface name parsing to 'delete vhost' command so an interface name can be provided. Change-Id: Iacd50545a63548c13b9bb3c36a98e08f6ad74429 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c
index decfebba1c3..1a2cf633fd9 100644
--- a/vnet/vnet/devices/virtio/vhost-user.c
+++ b/vnet/vnet/devices/virtio/vhost-user.c
@@ -2565,6 +2565,7 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, *line_input = &_line_input;
u32 sw_if_index = ~0;
+ vnet_main_t *vnm = vnet_get_main ();
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -2574,16 +2575,22 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
{
if (unformat (line_input, "sw_if_index %d", &sw_if_index))
;
+ else if (unformat
+ (line_input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
+ {
+ vnet_hw_interface_t *hwif =
+ vnet_get_sup_hw_interface (vnm, sw_if_index);
+ if (hwif == NULL ||
+ vhost_user_dev_class.index != hwif->dev_class_index)
+ return clib_error_return (0, "Not a vhost interface");
+ }
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
unformat_free (line_input);
-
- vnet_main_t *vnm = vnet_get_main ();
-
vhost_user_delete_if (vnm, vm, sw_if_index);
-
return 0;
}