monitor: Convert do_set_link() to QObject, QError
authorMarkus Armbruster <armbru@redhat.com>
Fri, 26 Mar 2010 08:07:11 +0000 (09:07 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 18 Apr 2010 21:55:19 +0000 (23:55 +0200)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
net.c
net.h
qemu-monitor.hx

diff --git a/net.c b/net.c
index cdba8f3571ce47b6158a3204a5ee6828141c241e..378edfccd0f2d5607e87a1e1cfa370cc87005dd3 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1271,7 +1271,7 @@ void do_info_network(Monitor *mon)
     }
 }
 
-void do_set_link(Monitor *mon, const QDict *qdict)
+int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     VLANState *vlan;
     VLANClientState *vc = NULL;
@@ -1289,8 +1289,8 @@ void do_set_link(Monitor *mon, const QDict *qdict)
 done:
 
     if (!vc) {
-        monitor_printf(mon, "could not find network device '%s'\n", name);
-        return;
+        qerror_report(QERR_DEVICE_NOT_FOUND, name);
+        return -1;
     }
 
     vc->link_down = !up;
@@ -1298,6 +1298,7 @@ done:
     if (vc->info->link_status_changed) {
         vc->info->link_status_changed(vc);
     }
+    return 0;
 }
 
 void net_cleanup(void)
diff --git a/net.h b/net.h
index 9f3c82fed5859aa0e861b6ac1158412ffba598a1..b83f6153466312416daf8cdb30c76f7f1cee6cae 100644 (file)
--- a/net.h
+++ b/net.h
@@ -118,7 +118,7 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
                         const char *default_model);
 
 void do_info_network(Monitor *mon);
-void do_set_link(Monitor *mon, const QDict *qdict);
+int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
 /* NIC info */
 
index 7b7dcf545ab48d1c055bb2e6b028f9262674491d..62fa3465b3d4d5a944a88926fc11f94bbabfc815 100644 (file)
@@ -989,7 +989,8 @@ ETEXI
         .args_type  = "name:s,up:b",
         .params     = "name on|off",
         .help       = "change the link status of a network adapter",
-        .mhandler.cmd = do_set_link,
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_set_link,
     },
 
 STEXI