1
From 193cc4abbb6c2fc5557d3699f86ff0103d5a21ef Mon Sep 17 00:00:00 2001
2
From: David Allan <dallan@redhat.com>
3
Date: Tue, 19 May 2009 16:47:31 -0400
4
Subject: [PATCH 8/8] Step 8 of 8 Add virsh support
7
src/virsh.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
1 files changed, 103 insertions(+), 0 deletions(-)
10
diff --git a/src/virsh.c b/src/virsh.c
11
index cb32ede..ab2a2b7 100644
14
@@ -2962,6 +2962,106 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
18
+ * "nodedev-create" command
20
+static const vshCmdInfo info_node_device_create[] = {
21
+ {"help", N_("create a device defined by an XML file on the node")},
22
+ {"desc", N_("Create a device on the node. Note that this "
23
+ "command creates devices on the physical host "
24
+ "that can then be assigned to a virtual machine.")},
28
+static const vshCmdOptDef opts_node_device_create[] = {
29
+ {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
30
+ N_("file containing an XML description of the device")},
35
+cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
37
+ virNodeDevicePtr dev = NULL;
43
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
46
+ from = vshCommandOptString(cmd, "file", &found);
51
+ if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
55
+ dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
59
+ vshPrint(ctl, _("Node device %s created from %s\n"),
60
+ virNodeDeviceGetName(dev), from);
62
+ vshError(ctl, FALSE, _("Failed to create node device from %s"), from);
71
+ * "nodedev-destroy" command
73
+static const vshCmdInfo info_node_device_destroy[] = {
74
+ {"help", N_("destroy a device on the node")},
75
+ {"desc", N_("Destroy a device on the node. Note that this "
76
+ "command destroys devices on the physical host")},
80
+static const vshCmdOptDef opts_node_device_destroy[] = {
81
+ {"name", VSH_OT_DATA, VSH_OFLAG_REQ,
82
+ N_("name of the device to be destroyed")},
87
+cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
89
+ virNodeDevicePtr dev = NULL;
94
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) {
98
+ name = vshCommandOptString(cmd, "name", &found);
103
+ dev = virNodeDeviceLookupByName(ctl->conn, name);
105
+ if (virNodeDeviceDestroy(dev) == 0) {
106
+ vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
108
+ vshError(ctl, FALSE, _("Failed to destroy node device '%s'"), name);
112
+ virNodeDeviceFree(dev);
118
* XML Building helper for pool-define-as and pool-create-as
120
static const vshCmdOptDef opts_pool_X_as[] = {
121
@@ -5895,6 +5996,8 @@ static const vshCmdDef commands[] = {
122
{"nodedev-dettach", cmdNodeDeviceDettach, opts_node_device_dettach, info_node_device_dettach},
123
{"nodedev-reattach", cmdNodeDeviceReAttach, opts_node_device_reattach, info_node_device_reattach},
124
{"nodedev-reset", cmdNodeDeviceReset, opts_node_device_reset, info_node_device_reset},
125
+ {"nodedev-create", cmdNodeDeviceCreate, opts_node_device_create, info_node_device_create},
126
+ {"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy, info_node_device_destroy},
128
{"pool-autostart", cmdPoolAutostart, opts_pool_autostart, info_pool_autostart},
129
{"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build},