From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com
Subject: [Qemu-devel] [PATCH] move net_handle_fd_param() into a common utility function
Date: Wed, 26 May 2010 17:31:50 -0400 [thread overview]
Message-ID: <20100526213030.9332.60231.stgit@virtlab9.virt.bos.redhat.com> (raw)
Move to monitor.c:monitor_handle_fd_param() as a common helper.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
I'd like to use this for the proposed device assignment configfd
parameter since there's nothing net specific about it.
monitor.c | 17 +++++++++++++++++
monitor.h | 1 +
net.c | 17 -----------------
net.h | 2 --
net/socket.c | 3 ++-
net/tap.c | 5 +++--
6 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/monitor.c b/monitor.c
index ad50f12..b7bf991 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2496,6 +2496,23 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
return -1;
}
+int monitor_handle_fd_param(Monitor *mon, const char *param)
+{
+ if (!qemu_isdigit(param[0])) {
+ int fd;
+
+ fd = monitor_get_fd(mon, param);
+ if (fd == -1) {
+ error_report("No file descriptor named %s found", param);
+ return -1;
+ }
+
+ return fd;
+ } else {
+ return strtol(param, NULL, 0);
+ }
+}
+
static const mon_cmd_t mon_cmds[] = {
#include "qemu-monitor.h"
{ NULL, NULL, },
diff --git a/monitor.h b/monitor.h
index ea15469..354c968 100644
--- a/monitor.h
+++ b/monitor.h
@@ -44,6 +44,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
void *opaque);
int monitor_get_fd(Monitor *mon, const char *fdname);
+int monitor_handle_fd_param(Monitor *mon, const char *param);
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap);
void monitor_printf(Monitor *mon, const char *fmt, ...)
diff --git a/net.c b/net.c
index 378edfc..af4ffaf 100644
--- a/net.c
+++ b/net.c
@@ -737,23 +737,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
return -1;
}
-int net_handle_fd_param(Monitor *mon, const char *param)
-{
- if (!qemu_isdigit(param[0])) {
- int fd;
-
- fd = monitor_get_fd(mon, param);
- if (fd == -1) {
- error_report("No file descriptor named %s found", param);
- return -1;
- }
-
- return fd;
- } else {
- return strtol(param, NULL, 0);
- }
-}
-
static int net_init_nic(QemuOpts *opts,
Monitor *mon,
const char *name,
diff --git a/net.h b/net.h
index b83f615..20b4840 100644
--- a/net.h
+++ b/net.h
@@ -177,6 +177,4 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
-int net_handle_fd_param(Monitor *mon, const char *param);
-
#endif
diff --git a/net/socket.c b/net/socket.c
index 1c4e153..89ccf1d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -31,6 +31,7 @@
#include "qemu-error.h"
#include "qemu-option.h"
#include "qemu_socket.h"
+#include "monitor.h"
typedef struct NetSocketState {
VLANClientState nc;
@@ -510,7 +511,7 @@ int net_init_socket(QemuOpts *opts,
return -1;
}
- fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
+ fd = monitor_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
diff --git a/net/tap.c b/net/tap.c
index 0147dab..645cc16 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -39,6 +39,7 @@
#include "qemu-char.h"
#include "qemu-common.h"
#include "qemu-error.h"
+#include "monitor.h"
#include "net/tap-linux.h"
@@ -413,7 +414,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
return -1;
}
- fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
+ fd = monitor_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
@@ -468,7 +469,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) {
int vhostfd, r;
if (qemu_opt_get(opts, "vhostfd")) {
- r = net_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
+ r = monitor_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
if (r == -1) {
return -1;
}
next reply other threads:[~2010-05-26 21:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 21:31 Alex Williamson [this message]
2010-05-27 5:45 ` [Qemu-devel] [PATCH] move net_handle_fd_param() into a common utility function Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100526213030.9332.60231.stgit@virtlab9.virt.bos.redhat.com \
--to=alex.williamson@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).