* [Qemu-devel] NetBSD qemu block device support
@ 2010-03-17 12:59 haad
2010-03-18 20:32 ` Blue Swirl
0 siblings, 1 reply; 4+ messages in thread
From: haad @ 2010-03-17 12:59 UTC (permalink / raw)
To: qemu-devel
Hi folks,
This patch at [1] add support for NetBSD block ioctl calls to qemu
block-raw.c file. It was written for xen version of qemu but basically
it will work with vanilla qemu, too. Would anyone like to commit this
patch so it can be included into the base xen distribution ?
[1] www.netbsd.org/~haad/block-raw.diff
--
Regards.
Adam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] NetBSD qemu block device support
2010-03-17 12:59 [Qemu-devel] NetBSD qemu block device support haad
@ 2010-03-18 20:32 ` Blue Swirl
2010-03-20 16:32 ` Christoph Hellwig
[not found] ` <19FEF06F-E51D-4D44-871B-CE0B2375F2E8@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Blue Swirl @ 2010-03-18 20:32 UTC (permalink / raw)
To: haad; +Cc: qemu-devel
On 3/17/10, haad <haad@netbsd.org> wrote:
> Hi folks,
>
> This patch at [1] add support for NetBSD block ioctl calls to qemu
> block-raw.c file. It was written for xen version of qemu but basically
> it will work with vanilla qemu, too. Would anyone like to commit this
> patch so it can be included into the base xen distribution ?
The patch does not apply to current development repository.
There is no description of the change suitable for changelog without
any editing.
Signed-off-by: line is missing.
The patch combines formatting (whitespace) changes with functional
changes. The formatting changes seem useless.
The essence of the patch is twofold, It adds NetBSD specific includes
and NetBSD specific code to raw_getlength(). These look OK, except
formatting may be a bit off (no space after if) and currently the code
probably should be surrounded by
#ifdef DIOCGWEDGEINFO
#endif
or just #ifdef __NetBSD__.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] NetBSD qemu block device support
2010-03-18 20:32 ` Blue Swirl
@ 2010-03-20 16:32 ` Christoph Hellwig
[not found] ` <19FEF06F-E51D-4D44-871B-CE0B2375F2E8@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2010-03-20 16:32 UTC (permalink / raw)
To: Blue Swirl; +Cc: haad, qemu-devel
On Thu, Mar 18, 2010 at 10:32:36PM +0200, Blue Swirl wrote:
> The patch does not apply to current development repository.
>
> There is no description of the change suitable for changelog without
> any editing.
>
> Signed-off-by: line is missing.
>
> The patch combines formatting (whitespace) changes with functional
> changes. The formatting changes seem useless.
>
> The essence of the patch is twofold, It adds NetBSD specific includes
> and NetBSD specific code to raw_getlength(). These look OK, except
> formatting may be a bit off (no space after if) and currently the code
> probably should be surrounded by
> #ifdef DIOCGWEDGEINFO
> #endif
> or just #ifdef __NetBSD__.
Also given the extreme mess that raw_getlength is I would much prefer
to give every new OS it's own copy of it, similar to how we already
handle OpenBSD today.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] NetBSD qemu block device support
[not found] ` <19FEF06F-E51D-4D44-871B-CE0B2375F2E8@gmail.com>
@ 2010-09-21 14:01 ` haad
0 siblings, 0 replies; 4+ messages in thread
From: haad @ 2010-09-21 14:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Sam Fourman Jr.
[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]
Hi,
On Mar,Thursday 18 2010, at 9:32 PM, Blue Swirl wrote:
> On 3/17/10, haad <haad@netbsd.org> wrote:
>> Hi folks,
>>
>> This patch at [1] add support for NetBSD block ioctl calls to qemu
>> block-raw.c file. It was written for xen version of qemu but basically
>> it will work with vanilla qemu, too. Would anyone like to commit this
>> patch so it can be included into the base xen distribution ?
>
> The patch does not apply to current development repository.
>
> There is no description of the change suitable for changelog without
> any editing.
>
> Signed-off-by: line is missing.
>
> The patch combines formatting (whitespace) changes with functional
> changes. The formatting changes seem useless.
>
> The essence of the patch is twofold, It adds NetBSD specific includes
> and NetBSD specific code to raw_getlength(). These look OK, except
> formatting may be a bit off (no space after if) and currently the code
> probably should be surrounded by
> #ifdef DIOCGWEDGEINFO
> #endif
> or just #ifdef __NetBSD__.
I have written this patch some time ago and then I totally forgot on
it (I'm very sorry about that)
Today I looked at it again and changed it to be clean and to properly
apply against current sources.
--
Regards.
Adam
[-- Attachment #2: netbsd-raw-posix.diff --]
[-- Type: text/x-diff, Size: 1200 bytes --]
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 72fb8ce..444fb2d 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -62,6 +62,12 @@
#include <sys/disklabel.h>
#include <sys/dkio.h>
#endif
+#if defined(__NetBSD__)
+#include <sys/ioctl.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#include <sys/disk.h>
+#endif
#ifdef __DragonFly__
#include <sys/ioctl.h>
@@ -595,6 +601,28 @@ static int64_t raw_getlength(BlockDriverState *bs)
} else
return st.st_size;
}
+#elif defined(__NetBSD__)
+static int64_t raw_getlength(BlockDriverState *bs)
+{
+ int fd = ((BDRVRawState*)bs->opaque)->fd;
+ struct stat st;
+ if (fstat(fd, &st))
+ return -1;
+ if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
+ struct dkwedge_info dkw;
+ if (ioctl(fd, DIOCGWEDGEINFO, &dkw) != -1) {
+ /* NetBSD still supports only 512 bytes for disk sector */
+ return dkw.dkw_size * 512;
+ } else {
+ struct disklabel dl;
+ if(ioctl(fd, DIOCGDINFO, &dl))
+ return -1;
+ return (uint64_t)dl.d_secsize *
+ dl.d_partitions[DISKPART(st.st_rdev)].p_size;
+ }
+ } else
+ return st.st_size;
+}
#elif defined(__sun__)
static int64_t raw_getlength(BlockDriverState *bs)
{
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-09-21 14:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 12:59 [Qemu-devel] NetBSD qemu block device support haad
2010-03-18 20:32 ` Blue Swirl
2010-03-20 16:32 ` Christoph Hellwig
[not found] ` <19FEF06F-E51D-4D44-871B-CE0B2375F2E8@gmail.com>
2010-09-21 14:01 ` haad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).