[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 2/3] qemu-agent: add guest-network-delete-interface co
From: |
Chen Fan |
Subject: |
[Qemu-devel] [RFC 2/3] qemu-agent: add guest-network-delete-interface command |
Date: |
Fri, 17 Apr 2015 16:53:12 +0800 |
Add a corresponding command to guest-network-set-interface.
Signed-off-by: Chen Fan <address@hidden>
---
qga/commands-posix.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
qga/commands-win32.c | 6 ++++++
qga/qapi-schema.json | 11 +++++++++++
3 files changed, 68 insertions(+)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 5ee7949..058085f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1971,6 +1971,51 @@ int64_t
qmp_guest_network_set_interface(GuestNetworkInterface2 *interface,
return 0;
}
+
+int64_t qmp_guest_network_delete_interface(const char *name, Error **errp)
+{
+ struct netcf_if *iface;
+ int ret = -1;
+ unsigned int flags = 0;
+
+ /* open netcf */
+ if (netcf == NULL) {
+ if (ncf_init(&netcf, NULL) != 0) {
+ error_setg(errp, "netcf init failed");
+ return ret;
+ }
+ }
+
+ iface = ncf_lookup_by_name(netcf, name);
+ if (!iface) {
+ error_setg(errp, "couldn't find interface named '%s'", name);
+ return ret;
+ }
+
+ if (ncf_if_status(iface, &flags) < 0) {
+ error_setg(errp, "netcf interface get status failed");
+ goto cleanup;
+ }
+
+ if (flags & NETCF_IFACE_ACTIVE) {
+ ret = ncf_if_down(iface);
+ if (ret < 0) {
+ error_setg(errp, "netcf interface stop failed");
+ goto cleanup;
+ }
+ }
+
+ ret = ncf_if_undefine(iface);
+ if (ret < 0) {
+ error_setg(errp, "netcf interface delete failed");
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ ncf_if_free(iface);
+ return ret;
+}
#else
int64_t qmp_guest_network_set_interface(GuestNetworkInterface2 *interface,
Error **errp)
@@ -1978,6 +2023,12 @@ int64_t
qmp_guest_network_set_interface(GuestNetworkInterface2 *interface,
error_set(errp, QERR_UNSUPPORTED);
return -1;
}
+
+int64_t qmp_guest_network_delete_interface(const char *name, Error **errp)
+{
+ error_set(errp, QERR_UNSUPPORTED);
+ return -1;
+}
#endif
#define SYSCONF_EXACT(name, errp) sysconf_exact((name), #name, (errp))
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 4c14514..52f6e47 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -453,6 +453,12 @@ int64_t
qmp_guest_network_set_interface(GuestNetworkInterface2 *interface,
return -1;
}
+int64_t qmp_guest_network_delete_interface(const char *name, Error **errp)
+{
+ error_set(errp, QERR_UNSUPPORTED);
+ return -1;
+}
+
/* add unsupported commands to the blacklist */
GList *ga_command_blacklist_init(GList *blacklist)
{
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 77f499b..b886f97 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -642,6 +642,17 @@
'returns': 'int' }
##
+# @guest-network-delete-interface:
+#
+# @name: interface name.
+#
+# Since: 2.3
+##
+{ 'command': 'guest-network-delete-interface',
+ 'data' : {'name': 'str' },
+ 'returns': 'int' }
+
+##
# @GuestLogicalProcessor:
#
# @logical-id: Arbitrary guest-specific unique identifier of the VCPU.
--
1.9.3
- [Qemu-devel] [RFC 0/7] Live Migration with Pass-through Devices proposal, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 1/7] qemu-agent: add agent init callback when detecting guest setup, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 2/7] qemu: add guest init event callback to do the initialize work for guest, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 3/7] hostdev: add a 'bond' type element in <hostdev> element, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 4/7] qemu-agent: add qemuAgentCreateBond interface, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 6/7] migrate: hot remove hostdev at perform phase for bond device, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 5/7] hostdev: add parse ip and route for bond configure, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 0/3] add support migration with passthrough device, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 7/7] migrate: add hostdev migrate status to support hostdev migration, Chen Fan, 2015/04/17
- Re: [Qemu-devel] [libvirt] [RFC 0/7] Live Migration with Pass-through Devices proposal, Laine Stump, 2015/04/19
- Re: [Qemu-devel] [RFC 0/7] Live Migration with Pass-through Devices proposal, Daniel P. Berrange, 2015/04/22