diff mbox

[v2,4/4] monitor: Convert do_set_link() to QObject, QError

Message ID 1269590831-26185-5-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster March 26, 2010, 8:07 a.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 net.c           |    7 ++++---
 net.h           |    2 +-
 qemu-monitor.hx |    3 ++-
 3 files changed, 7 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/net.c b/net.c
index 830021d..2559c07 100644
--- a/net.c
+++ b/net.c
@@ -1283,7 +1283,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;
@@ -1301,8 +1301,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;
@@ -1310,6 +1310,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 ce9e2c6..c7a3a1b 100644
--- 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 */
 
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 7b7dcf5..62fa346 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -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