~serge-hallyn/ubuntu/oneiric/libvirt/fix-shutdown

« back to all changes in this revision

Viewing changes to docs/api_extension/0008-Step-8-of-8-Add-virsh-support.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-11-02 16:26:51 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20101102162651-aq8tnbz58mdf01bf
Tags: 0.8.5-0ubuntu1
* New upstream release.
* Removed a slew of patches which have been
  applied upstream since 0.8.3.
  - 9012-apparmor-extra-tests.patch
  - 9013-apparmor-chardev.patch
  - 9015-Add-ubd-to-the-list-of-disk-prefixes.patch
  - 9016-Close-fd-s-of-persistent-tap-devices.patch
  - 9017-Make-sure-all-command-line-arguments-get-passed-to-U.patch
  - 9018-Make-umlConnectTapDevice-ask-brAddTap-for-a-persiste.patch
  - 9019-uml-fix-logic-bug-in-checking-reply-length.patch
  - 9021-Allow-chardev-of-type-file-for-UML-domains.patch
  - 9022-Rename-qemudShrinkDisks-to-virDomainDiskRemove-and-m.patch
  - 9023-Support-virDomainAttachDevice-and-virDomainDetachDev.patch
  - 9024-Explicitly-pass-uml_dir-argument-to-user-mode-linux.patch
  - 9025-Add-nwfilter-support-to-UML-driver.patch
  - 9026-Rebuild-network-filter-for-UML-guests-on-updates.patch
  - 9027-Make-newfilter-xml-transformations-endian-safe.patch
  - 9028-lp628055.patch
* Updated 9002-better_default_uri_virsh.patch to use vshStrdup,
  as now required in that file.  (use of strdup now causes compilation
  to fail)
* Removed 9008-run-as-root-by-default.patch, which has not been
  applied for awhile now, with no ill effects.
* Simple refresh of:
  - 0001-remove-RHism.diff.patch
  - 0003-allow-libvirt-group-to-access-the-socket.patch
  - 0004-fix-Debian-specific-path-to-hvm-loader.patch
  - 0006-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
  - 9000-delayed_iff_up_bridge.patch
  - 9001-dont_clobber_existing_bridges.patch
  - 9003-better-default-arch.patch
  - 9004-libvirtd-group-name.patch
  - 9005-increase-unix-socket-timeout.patch
  - 9006-default-config-test-case.patch
  - 9009-autodetect-nc-params.patch
  - 9010-dont-disable-ipv6.patch
  - 9011-move-ebtables-script.patch
  - 9014-skip-nodeinfotest.patch
  - 9020-lp545795.patch
* Create a patch to include stdint.h so lxc_container.h, which
  #includes linux/fs.h, doesn't trip up on undefined uint64_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
 
 
6
 
---
7
 
 src/virsh.c |  103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
 
 1 files changed, 103 insertions(+), 0 deletions(-)
9
 
 
10
 
diff --git a/src/virsh.c b/src/virsh.c
11
 
index cb32ede..ab2a2b7 100644
12
 
--- a/src/virsh.c
13
 
+++ b/src/virsh.c
14
 
@@ -2962,6 +2962,106 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
15
 
 
16
 
 
17
 
 /*
18
 
+ * "nodedev-create" command
19
 
+ */
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.")},
25
 
+    {NULL, NULL}
26
 
+};
27
 
+
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")},
31
 
+    {NULL, 0, 0, NULL}
32
 
+};
33
 
+
34
 
+static int
35
 
+cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
36
 
+{
37
 
+    virNodeDevicePtr dev = NULL;
38
 
+    char *from;
39
 
+    int found = 0;
40
 
+    int ret = TRUE;
41
 
+    char *buffer;
42
 
+
43
 
+    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
44
 
+        return FALSE;
45
 
+
46
 
+    from = vshCommandOptString(cmd, "file", &found);
47
 
+    if (!found) {
48
 
+        return FALSE;
49
 
+    }
50
 
+
51
 
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
52
 
+        return FALSE;
53
 
+    }
54
 
+
55
 
+    dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
56
 
+    free (buffer);
57
 
+
58
 
+    if (dev != NULL) {
59
 
+        vshPrint(ctl, _("Node device %s created from %s\n"),
60
 
+                 virNodeDeviceGetName(dev), from);
61
 
+    } else {
62
 
+        vshError(ctl, FALSE, _("Failed to create node device from %s"), from);
63
 
+        ret = FALSE;
64
 
+    }
65
 
+
66
 
+    return ret;
67
 
+}
68
 
+
69
 
+
70
 
+/*
71
 
+ * "nodedev-destroy" command
72
 
+ */
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")},
77
 
+    {NULL, NULL}
78
 
+};
79
 
+
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")},
83
 
+    {NULL, 0, 0, NULL}
84
 
+};
85
 
+
86
 
+static int
87
 
+cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
88
 
+{
89
 
+    virNodeDevicePtr dev = NULL;
90
 
+    int ret = TRUE;
91
 
+    int found = 0;
92
 
+    char *name;
93
 
+
94
 
+    if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) {
95
 
+        return FALSE;
96
 
+    }
97
 
+
98
 
+    name = vshCommandOptString(cmd, "name", &found);
99
 
+    if (!found) {
100
 
+        return FALSE;
101
 
+    }
102
 
+
103
 
+    dev = virNodeDeviceLookupByName(ctl->conn, name);
104
 
+
105
 
+    if (virNodeDeviceDestroy(dev) == 0) {
106
 
+        vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
107
 
+    } else {
108
 
+        vshError(ctl, FALSE, _("Failed to destroy node device '%s'"), name);
109
 
+        ret = FALSE;
110
 
+    }
111
 
+
112
 
+    virNodeDeviceFree(dev);
113
 
+    return ret;
114
 
+}
115
 
+
116
 
+
117
 
+/*
118
 
  * XML Building helper for pool-define-as and pool-create-as
119
 
  */
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},
127
 
 
128
 
     {"pool-autostart", cmdPoolAutostart, opts_pool_autostart, info_pool_autostart},
129
 
     {"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build},
130
 
1.6.0.6