All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: How to change backing file ?
@ 2020-12-28 18:03 Kevin Nguetchouang
  2021-01-03 10:35 ` Kevin Nguetchouang
  2021-01-09  9:50 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Nguetchouang @ 2020-12-28 18:03 UTC (permalink / raw)
  To: qemu-devel

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

Hello everyone, in a class project, i would like to change the backing file
of the current image opened with a particular path file.

I try differents functions i saw in the source code
- bdrv_change_backing_file
- bdrv_open
- bdrv_open_child

but no one work... from segmentation fault error to bdrv_attach_backing
passing through parent->blocking_error, i don't know how to achieve what i
want.

-- 
*Kevin Nguetchouang.*

[-- Attachment #2: Type: text/html, Size: 681 bytes --]

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

* Re: Question: How to change backing file ?
  2020-12-28 18:03 Question: How to change backing file ? Kevin Nguetchouang
@ 2021-01-03 10:35 ` Kevin Nguetchouang
  2021-01-04 13:25   ` Kashyap Chamarthy
  2021-01-09  9:50 ` Vladimir Sementsov-Ogievskiy
  1 sibling, 1 reply; 4+ messages in thread
From: Kevin Nguetchouang @ 2021-01-03 10:35 UTC (permalink / raw)
  To: qemu-devel

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

nobody then ?

Le lun. 28 déc. 2020 à 19:03, Kevin Nguetchouang <
kevinnguetchouang@gmail.com> a écrit :

> Hello everyone, in a class project, i would like to change the backing
> file of the current image opened with a particular path file.
>
> I try differents functions i saw in the source code
> - bdrv_change_backing_file
> - bdrv_open
> - bdrv_open_child
>
> but no one work... from segmentation fault error to bdrv_attach_backing
> passing through parent->blocking_error, i don't know how to achieve what i
> want.
>
> --
> *Kevin Nguetchouang.*
>


-- 
*Kevin Nguetchouang.*

[-- Attachment #2: Type: text/html, Size: 1156 bytes --]

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

* Re: Question: How to change backing file ?
  2021-01-03 10:35 ` Kevin Nguetchouang
@ 2021-01-04 13:25   ` Kashyap Chamarthy
  0 siblings, 0 replies; 4+ messages in thread
From: Kashyap Chamarthy @ 2021-01-04 13:25 UTC (permalink / raw)
  To: Kevin Nguetchouang; +Cc: qemu-devel, qemu-block

[Cc: qemu-block]

On Sun, Jan 03, 2021 at 11:35:49AM +0100, Kevin Nguetchouang wrote:
> nobody then ?

[No direct answer but a quick meta note ...]

... if you're looking for guidance on code internals, you might want to
wait a little more time for the block developers to notice.  Some
regions of the world have time off at the end of the year, and might
just be coming online.

For you might want to Cc (I've done that now) qemu-block@nongnu.org
list, a block-layer related mailing list.

> 
> Le lun. 28 déc. 2020 à 19:03, Kevin Nguetchouang <
> kevinnguetchouang@gmail.com> a écrit :
> 
> > Hello everyone, in a class project, i would like to change the backing
> > file of the current image opened with a particular path file.
> >
> > I try differents functions i saw in the source code
> > - bdrv_change_backing_file
> > - bdrv_open
> > - bdrv_open_child
> >
> > but no one work... from segmentation fault error to bdrv_attach_backing
> > passing through parent->blocking_error, i don't know how to achieve what i
> > want.
> >
> > --
> > *Kevin Nguetchouang.*
> >
> 
> 
> -- 
> *Kevin Nguetchouang.*

-- 
/kashyap



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

* Re: Question: How to change backing file ?
  2020-12-28 18:03 Question: How to change backing file ? Kevin Nguetchouang
  2021-01-03 10:35 ` Kevin Nguetchouang
@ 2021-01-09  9:50 ` Vladimir Sementsov-Ogievskiy
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2021-01-09  9:50 UTC (permalink / raw)
  To: Kevin Nguetchouang, qemu-devel

Hi Kevin!

28.12.2020 21:03, Kevin Nguetchouang wrote:
> Hello everyone, in a class project, i would like to change the backing file of the current image opened with a particular path file.
> 
> I try differents functions i saw in the source code
> - bdrv_change_backing_file
> - bdrv_open
> - bdrv_open_child
> 
> but no one work... from segmentation fault error to bdrv_attach_backing passing through parent->blocking_error, i don't know how to achieve what i want.
> 
> -- 
> /Kevin Nguetchouang./

First, you should understand, that there are two different thing in "changing the backing file":

1. Change backing link in the block nodes graph
2. Change backing file name in the metadata of the image (for example in qcow2 header

For example, look at the bdrv_drop_intermediate() (block.c) function. it's aim is to drop all nodes in the chain between top and base, and make base to be new backing file for the top.

Key things in the function:

- bdrv_subtree_drained_begin/end - to pause any io operations during graph update

- bdrv_replace_node_common() - which actually replace backing child of top node

- c->klass->update_filename() - which will update backing-file in the metadata of top image


Another example in block/stream.c, in stream_prepare():

- bdrv_set_backing_hd() to change backing child
- bdrv_change_backing_file() to change backing-file in the metadata of top image


(hmm, why don't we have drained begin/end here? why we don't use bdrv_drop_intermediate()? - just good questions).


Hope, it helps a bit.


-- 
Best regards,
Vladimir


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

end of thread, other threads:[~2021-01-09  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 18:03 Question: How to change backing file ? Kevin Nguetchouang
2021-01-03 10:35 ` Kevin Nguetchouang
2021-01-04 13:25   ` Kashyap Chamarthy
2021-01-09  9:50 ` Vladimir Sementsov-Ogievskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.