
On 05/05/2010 08:52 AM, Wolfgang Mauerer wrote:
We can reuse some of the code for other purposes.
Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com> --- src/qemu/qemu_driver.c | 56 ++++++++++++++++++++++++++++++----------------- 1 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 47ae52c..63ca57c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7867,6 +7867,36 @@ cleanup: }
+static inline int qemudFindDisk(virDomainDefPtr def, char *dst)
dst can be const char *.
+{ + int i; + + for (i = 0 ; i < def->ndisks ; i++) { + if (STREQ(def->disks[i]->dst, dst)) { + return i; + } + } + + return -1; +} + +static inline void qemudShrinkDisks(virDomainDefPtr def, int i)
And i can be unsigned (better yet, size_t).
+{ + if (def->ndisks > 1) { + memmove(def->disks + i, + def->disks + i + 1, + sizeof(*def->disks) * + (def->ndisks - (i + 1))); + def->ndisks--; + if (VIR_REALLOC_N(def->disks, def->ndisks) < 0) { + /* ignore, harmless */ + } + } else { + VIR_FREE(def->disks); + def->ndisks = 0; + } +}
But since this is just code motion for future use, it looks fine to me. ACK, and I went ahead and pushed it with those edits. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org