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

Re: [libvirt] [PATCH] in Vbox driver, OpenHardDisk is called with NULL instead of ""



On Tuesday 29 September 2009 12:27:49 Florian Vichot wrote:
> This patch replaces the use of NULL with empty strings ("") in a call to
> OpenHardDisk, which otherwise fails with E_INVALIDARG.

The patch fix's it but the more appropriate fix would be as below.

Regards,
Pritesh

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 07515fe..0c9fff0 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3199,7 +3199,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                         if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE) {
                             IHardDisk *hardDisk     = NULL;
                             PRUnichar *hddfileUtf16 = NULL;
-                            vboxIID *hdduuid        = NULL;
+                            vboxIID   *hdduuid      = NULL;
+                            PRUnichar *hddEmpty     = NULL;
                             /* Current Limitation: Harddisk can't be connected to
                              * Secondary Master as Secondary Master is always used
                              * for CD/DVD Drive, so don't connect the harddisk if it
@@ -3207,6 +3208,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                              */
 
                             data->pFuncs->pfnUtf8ToUtf16(def->disks[i]->src, &hddfileUtf16);
+                            data->pFuncs->pfnUtf8ToUtf16("", &hddEmpty);
 
                             data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddfileUtf16, &hardDisk);
 
@@ -3221,9 +3223,9 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                                                                   hddfileUtf16,
                                                                   AccessMode_ReadWrite,
                                                                   0,
-                                                                  NULL,
+                                                                  hddEmpty,
                                                                   0,
-                                                                  NULL,
+                                                                  hddEmpty,
                                                                   &hardDisk);
 #endif
                             }
@@ -3286,6 +3288,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                                 hardDisk->vtbl->imedium.nsisupports.Release((nsISupports *)hardDisk);
                             }
                             vboxIIDUnalloc(hdduuid);
+                            data->pFuncs->pfnUtf16Free(hddEmpty);
                             data->pFuncs->pfnUtf16Free(hddfileUtf16);
                         } else if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
                         }

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