vhost: CLI delete interface by name 00/3900/2
authorPierre Pfister <ppfister@cisco.com>
Mon, 21 Nov 2016 12:52:22 +0000 (12:52 +0000)
committerDamjan Marion <dmarion.lists@gmail.com>
Thu, 24 Nov 2016 09:35:15 +0000 (09:35 +0000)
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>
vnet/vnet/devices/virtio/vhost-user.c

index decfebb..1a2cf63 100644 (file)
@@ -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;
 }