Received: from eggs.gnu.org ([2001:4830:134:3::10]:54961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab9oe-0000HN-QF for qemu-devel@nongnu.org; Wed, 02 Mar 2016 11:40:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ab9ob-0003JJ-FZ for qemu-devel@nongnu.org; Wed, 02 Mar 2016 11:40:00 -0500 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: <20160302090231.GB4494@noname.redhat.com> Date: Wed, 2 Mar 2016 11:39:54 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <1F537F4B-2881-46B7-81B2-D36CDDA7EA21@gmail.com> References: <3BAC5050-04A8-44DA-B65F-424CFE5615DA@gmail.com> <20160301151639.GF4250@noname.str.redhat.com> <20160302090231.GB4494@noname.redhat.com> Subject: Re: [Qemu-devel] ping [PATCH v14] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel qemu-devel , Qemu-block On Mar 2, 2016, at 4:02 AM, Kevin Wolf wrote: > Am 02.03.2016 um 04:32 hat Programmingkid geschrieben: >>=20 >> On Mar 1, 2016, at 10:16 AM, Kevin Wolf wrote: >>=20 >>> Am 29.02.2016 um 16:17 hat Programmingkid geschrieben: >>>> I do think this patch is ready to be added to QEMU. I have listened = to what you said and implemented your changes.=20 >>>>=20 >>>> https://patchwork.ozlabs.org/patch/579325/ >>>>=20 >>>> Mac OS X can be picky when it comes to allowing the user >>>> to use physical devices in QEMU. Most mounted volumes >>>> appear to be off limits to QEMU. If an issue is detected, >>>> a message is displayed showing the user how to unmount a >>>> volume. Now QEMU uses both CD and DVD media. >>>>=20 >>>> Signed-off-by: John Arbuckle >>>>=20 >>>> --- >>>> Changed filename variable to const char * type. >>>> Removed snprintf call for filename variable. >>>> filename is set to bsd_path if using a physical device that isn't a = DVD or CD. >>>=20 >>>> @@ -2112,33 +2166,57 @@ static int hdev_open(BlockDriverState *bs, = QDict *options, int flags, >>>>=20 >>>> #if defined(__APPLE__) && defined(__MACH__) >>>> const char *filename =3D qdict_get_str(options, "filename"); >>>> + char bsd_path[MAXPATHLEN] =3D ""; >>>> + bool error_occurred =3D false; >>>> + =20 >>>=20 >>> This line adds trailing whitespace. >>>=20 >>>> @@ -2147,7 +2225,16 @@ static int hdev_open(BlockDriverState *bs, = QDict *options, int flags, >>>> if (local_err) { >>>> error_propagate(errp, local_err); >>>> } >>>> - return ret; >>>> +#if defined(__APPLE__) && defined(__MACH__) >>>> + if (*bsd_path) { >>>> + filename =3D bsd_path; >>>> + } >>>> + /* if a physical device experienced an error while being = opened */ >>>> + if (strncmp(filename, "/dev/", 5) =3D=3D 0) { >>>> + print_unmounting_directions(filename); >>>> + return -1; >>>=20 >>> Please use a negative errno number instead of -1. >>=20 >> Is this ok: >> return -EPERM; >>=20 >> According to http://man7.org/linux/man-pages/man3/errno.3.html, it = means "operation not permitted". >=20 > Well, to be honest I don't understand why there is a different error > code here to begin with. Maybe when you add the "return ret" back = after > the #endif you can just leave out this line and return the real error > code this way. I like this idea more. >=20 > If for some reason (that I fail to understand) ret doesn't contain an > appropriate error code in this case, though, you can return a = constant. > If it's related to permissions, -EPERM is okay, otherwise it's = probably > not. I don't see a connection between paths starting with /dev/ and > there being a permission problem. I have placed "return ret;" right after the #endif and removed the = "return -1" in the if condition because it is now redundant. Does this = look right: if (ret < 0) { if (local_err) { error_propagate(errp, local_err); } #if defined(__APPLE__) && defined(__MACH__) if (*bsd_path) { filename =3D bsd_path; } /* if a physical device experienced an error while being opened = */ if (strncmp(filename, "/dev/", 5) =3D=3D 0) { print_unmounting_directions(filename); } #endif /* defined(__APPLE__) && defined(__MACH__) */ return ret; } >=20 >> Did you want this -1 changed also? >> +hdev_open_Mac_error: >> + g_free(mediaType); >> + if (mediaIterator) { >> + IOObjectRelease(mediaIterator); >> + } >> + if (error_occurred) { >> + return -1; >> + } >=20 > Yes, please, I missed that one. We don't have a valid ret here, so = maybe > -ENOENT would be the closest one? Ok. >=20 >>> But more importantly: What happened with the return that you removed >>> above? Even in the non-Apple case, we don't return an error now, but >>> continue in this function. This looks certainly wrong. Did you = intend to >>> move it to below the #ifdef block? >>=20 >> Good catch. I will place it right below the #endif /* = defined(__APPLE__) && defined(__MACH__) */.=20 >=20 > Thanks. >=20 > Kevin Thank you.=