qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/nvme: Do not allow image creation with NVMe block driver
@ 2020-12-04 16:57 Philippe Mathieu-Daudé
  2020-12-04 22:28 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-04 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Kevin Wolf, qemu-block, Max Reitz, Stefan Hajnoczi,
	Maxim Levitsky, Xueqiang Wei, Philippe Mathieu-Daudé

The NVMe driver does not support image creation.
The full drive has to be passed to the guest.

Before:

  $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
  Formatting 'nvme://0000:04:00.0/1', fmt=raw size=21474836480

  $ qemu-img info nvme://0000:04:00.0/1
  image: nvme://0000:04:00.0/1
  file format: raw
  virtual size: 349 GiB (375083606016 bytes)
  disk size: unavailable

After:

  $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
  qemu-img: nvme://0000:04:00.0/1: Protocol driver 'nvme' does not support image creation

Fixes: 5a5e7f8cd86 ("block: trickle down the fallback image creation function use to the block drivers")
Reported-by: Xueqiang Wei <xuwei@redhat.com>
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Cc: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/nvme.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/nvme.c b/block/nvme.c
index a06a188d530..73ddf837c2b 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -1515,9 +1515,6 @@ static BlockDriver bdrv_nvme = {
     .protocol_name            = "nvme",
     .instance_size            = sizeof(BDRVNVMeState),
 
-    .bdrv_co_create_opts      = bdrv_co_create_opts_simple,
-    .create_opts              = &bdrv_create_opts_simple,
-
     .bdrv_parse_filename      = nvme_parse_filename,
     .bdrv_file_open           = nvme_file_open,
     .bdrv_close               = nvme_close,
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/nvme: Do not allow image creation with NVMe block driver
  2020-12-04 16:57 [PATCH] block/nvme: Do not allow image creation with NVMe block driver Philippe Mathieu-Daudé
@ 2020-12-04 22:28 ` Philippe Mathieu-Daudé
  2020-12-07 17:16   ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-04 22:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Kevin Wolf, qemu-block, Max Reitz, Stefan Hajnoczi,
	Maxim Levitsky, Xueqiang Wei

On 12/4/20 5:57 PM, Philippe Mathieu-Daudé wrote:
> The NVMe driver does not support image creation.
> The full drive has to be passed to the guest.
> 
> Before:
> 
>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
>   Formatting 'nvme://0000:04:00.0/1', fmt=raw size=21474836480
> 
>   $ qemu-img info nvme://0000:04:00.0/1
>   image: nvme://0000:04:00.0/1
>   file format: raw
>   virtual size: 349 GiB (375083606016 bytes)
>   disk size: unavailable
> 
> After:
> 
>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
>   qemu-img: nvme://0000:04:00.0/1: Protocol driver 'nvme' does not support image creation
> 
> Fixes: 5a5e7f8cd86 ("block: trickle down the fallback image creation function use to the block drivers")
> Reported-by: Xueqiang Wei <xuwei@redhat.com>
> Suggested-by: Max Reitz <mreitz@redhat.com>

Well Max didn't suggest the change but pointed me to commit 5a5e7f8cd86.

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Cc: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  block/nvme.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/block/nvme.c b/block/nvme.c
> index a06a188d530..73ddf837c2b 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -1515,9 +1515,6 @@ static BlockDriver bdrv_nvme = {
>      .protocol_name            = "nvme",
>      .instance_size            = sizeof(BDRVNVMeState),
>  
> -    .bdrv_co_create_opts      = bdrv_co_create_opts_simple,
> -    .create_opts              = &bdrv_create_opts_simple,
> -
>      .bdrv_parse_filename      = nvme_parse_filename,
>      .bdrv_file_open           = nvme_file_open,
>      .bdrv_close               = nvme_close,
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/nvme: Do not allow image creation with NVMe block driver
  2020-12-04 22:28 ` Philippe Mathieu-Daudé
@ 2020-12-07 17:16   ` Philippe Mathieu-Daudé
  2020-12-17 16:17     ` Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-07 17:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Kevin Wolf, qemu-block, Max Reitz, Stefan Hajnoczi,
	Maxim Levitsky, Xueqiang Wei

On 12/4/20 11:28 PM, Philippe Mathieu-Daudé wrote:
> On 12/4/20 5:57 PM, Philippe Mathieu-Daudé wrote:
>> The NVMe driver does not support image creation.
>> The full drive has to be passed to the guest.
>>
>> Before:
>>
>>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
>>   Formatting 'nvme://0000:04:00.0/1', fmt=raw size=21474836480
>>
>>   $ qemu-img info nvme://0000:04:00.0/1
>>   image: nvme://0000:04:00.0/1
>>   file format: raw
>>   virtual size: 349 GiB (375083606016 bytes)
>>   disk size: unavailable

Maybe I should not forbid all formats... But 'raw' is kinda
dangerous, as there is no way to enforce the next layer to
access beside the size allocated.

Safe drive partitioning can be achieved creating namespaces,
feature which is not yet implemented.

>>
>> After:
>>
>>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
>>   qemu-img: nvme://0000:04:00.0/1: Protocol driver 'nvme' does not support image creation
>>
>> Fixes: 5a5e7f8cd86 ("block: trickle down the fallback image creation function use to the block drivers")
>> Reported-by: Xueqiang Wei <xuwei@redhat.com>
>> Suggested-by: Max Reitz <mreitz@redhat.com>
> 
> Well Max didn't suggest the change but pointed me to commit 5a5e7f8cd86.
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> Cc: Maxim Levitsky <mlevitsk@redhat.com>
>> ---
>>  block/nvme.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/block/nvme.c b/block/nvme.c
>> index a06a188d530..73ddf837c2b 100644
>> --- a/block/nvme.c
>> +++ b/block/nvme.c
>> @@ -1515,9 +1515,6 @@ static BlockDriver bdrv_nvme = {
>>      .protocol_name            = "nvme",
>>      .instance_size            = sizeof(BDRVNVMeState),
>>  
>> -    .bdrv_co_create_opts      = bdrv_co_create_opts_simple,
>> -    .create_opts              = &bdrv_create_opts_simple,
>> -
>>      .bdrv_parse_filename      = nvme_parse_filename,
>>      .bdrv_file_open           = nvme_file_open,
>>      .bdrv_close               = nvme_close,
>>
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/nvme: Do not allow image creation with NVMe block driver
  2020-12-07 17:16   ` Philippe Mathieu-Daudé
@ 2020-12-17 16:17     ` Stefan Hajnoczi
  2020-12-18 10:20       ` Kevin Wolf
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2020-12-17 16:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Kevin Wolf, qemu-block, qemu-devel, Max Reitz,
	Maxim Levitsky, Xueqiang Wei

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

On Mon, Dec 07, 2020 at 06:16:04PM +0100, Philippe Mathieu-Daudé wrote:
> On 12/4/20 11:28 PM, Philippe Mathieu-Daudé wrote:
> > On 12/4/20 5:57 PM, Philippe Mathieu-Daudé wrote:
> >> The NVMe driver does not support image creation.
> >> The full drive has to be passed to the guest.
> >>
> >> Before:
> >>
> >>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
> >>   Formatting 'nvme://0000:04:00.0/1', fmt=raw size=21474836480
> >>
> >>   $ qemu-img info nvme://0000:04:00.0/1
> >>   image: nvme://0000:04:00.0/1
> >>   file format: raw
> >>   virtual size: 349 GiB (375083606016 bytes)
> >>   disk size: unavailable
> 
> Maybe I should not forbid all formats... But 'raw' is kinda
> dangerous, as there is no way to enforce the next layer to
> access beside the size allocated.
> 
> Safe drive partitioning can be achieved creating namespaces,
> feature which is not yet implemented.

I don't see the need for this patch. Or if there is a need then
block/file-posix.c, block/iscsi.c, and block/nbd.c should also be
changed (anything that uses bdrv_co_create_opts_simple()).

Instead I suggest adding a warning at creation time if a raw format
image is created on top of a BDS that is larger than requested. The
warning should remind the user that they need to use the raw format
drivers's size= open option to restrict the disk capacity when opening
the image.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/nvme: Do not allow image creation with NVMe block driver
  2020-12-17 16:17     ` Stefan Hajnoczi
@ 2020-12-18 10:20       ` Kevin Wolf
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2020-12-18 10:20 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Fam Zheng, Maxim Levitsky, qemu-block, qemu-devel, Max Reitz,
	Xueqiang Wei, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Am 17.12.2020 um 17:17 hat Stefan Hajnoczi geschrieben:
> On Mon, Dec 07, 2020 at 06:16:04PM +0100, Philippe Mathieu-Daudé wrote:
> > On 12/4/20 11:28 PM, Philippe Mathieu-Daudé wrote:
> > > On 12/4/20 5:57 PM, Philippe Mathieu-Daudé wrote:
> > >> The NVMe driver does not support image creation.
> > >> The full drive has to be passed to the guest.
> > >>
> > >> Before:
> > >>
> > >>   $ qemu-img create -f raw nvme://0000:04:00.0/1 20G
> > >>   Formatting 'nvme://0000:04:00.0/1', fmt=raw size=21474836480
> > >>
> > >>   $ qemu-img info nvme://0000:04:00.0/1
> > >>   image: nvme://0000:04:00.0/1
> > >>   file format: raw
> > >>   virtual size: 349 GiB (375083606016 bytes)
> > >>   disk size: unavailable
> > 
> > Maybe I should not forbid all formats... But 'raw' is kinda
> > dangerous, as there is no way to enforce the next layer to
> > access beside the size allocated.
> > 
> > Safe drive partitioning can be achieved creating namespaces,
> > feature which is not yet implemented.
> 
> I don't see the need for this patch. Or if there is a need then
> block/file-posix.c, block/iscsi.c, and block/nbd.c should also be
> changed (anything that uses bdrv_co_create_opts_simple()).
> 
> Instead I suggest adding a warning at creation time if a raw format
> image is created on top of a BDS that is larger than requested. The
> warning should remind the user that they need to use the raw format
> drivers's size= open option to restrict the disk capacity when opening
> the image.

This sounds like a good idea to me.

Kevin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-18 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 16:57 [PATCH] block/nvme: Do not allow image creation with NVMe block driver Philippe Mathieu-Daudé
2020-12-04 22:28 ` Philippe Mathieu-Daudé
2020-12-07 17:16   ` Philippe Mathieu-Daudé
2020-12-17 16:17     ` Stefan Hajnoczi
2020-12-18 10:20       ` Kevin Wolf

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).