[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] virsh: Increase device-detach intelligence



On 04/05/2011 12:14 AM, Eric Blake wrote:
On 03/25/2011 09:09 AM, Michal Privoznik wrote:
Up to now users have to give a full XML description on input when
device-detaching. If they omited something it lead to unclear
error messages (like generated MAC wasn't found, etc.).
With this patch users can specify only those information which
specify one device sufficiently precise. Remaining information is
completed from domain.
---
  tools/virsh.c |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
  1 files changed, 245 insertions(+), 15 deletions(-)

Not forgotten, but not quite yet to the top of my queue, either :(  I
guess having too many patches to review is a good sign that there is a
lot of contribution going on.


diff --git a/tools/virsh.c b/tools/virsh.c
index 50ca50f..95d27f7 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8702,6 +8702,224 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
      return TRUE;
  }

+/**
+ * Check if n1 is superset of n2, meaning n1 contains all elements and
+ * attributes as n2 at lest. Including children.
+ * @n1 first node
+ * @n2 second node
+ * return 1 in case n1 covers n2, 0 otherwise.
+ */
+static int
+vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) {

Are there any xml library functions that can already do this without you
rewriting it from scratch?
No, there are not. I consulted this issue with Daniel Veillard.

+/**
+ * To given domain and (probably incomplete) device XML specification try to
+ * find such device in domain and complete missing parts. This is however
+ * possible when given device XML is sufficiently precise so it addresses only
+ * one device.
+ * @ctl vshControl for error messages printing
+ * @dom domain
+ * @oldXML device XML before
+ * @newXML and after completion
+ * Returns -2 when no such device exists in domain, -3 when given XML selects many
+ *          (is too ambiguous), 0 in case of success. Otherwise returns -1. @newXML
+ *          is touched only in case of success.
+ */
+static int
+vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML,
+                         char **newXML) {

My quick glance of just the documentation says that this looks like a
nice helper, but I haven't reviewed it in depth.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]