diff mbox

[V9,01/14] block: move bdrv_snapshot_find() to block/snapshot.c

Message ID 1363000996-13221-2-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia March 11, 2013, 11:23 a.m. UTC
This patch adds block/snapshot.c and then moves the function
there. It also fixes small code style errors reported by check script.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block/Makefile.objs      |    1 +
 block/snapshot.c         |   37 +++++++++++++++++++++++++++++++++++++
 include/block/snapshot.h |   26 ++++++++++++++++++++++++++
 savevm.c                 |   23 +----------------------
 4 files changed, 65 insertions(+), 22 deletions(-)
 create mode 100644 block/snapshot.c
 create mode 100644 include/block/snapshot.h

Comments

Eric Blake March 11, 2013, 5:49 p.m. UTC | #1
On 03/11/2013 05:23 AM, Wenchao Xia wrote:
>   This patch adds block/snapshot.c and then moves the function
> there. It also fixes small code style errors reported by check script.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block/Makefile.objs      |    1 +
>  block/snapshot.c         |   37 +++++++++++++++++++++++++++++++++++++
>  include/block/snapshot.h |   26 ++++++++++++++++++++++++++
>  savevm.c                 |   23 +----------------------
>  4 files changed, 65 insertions(+), 22 deletions(-)
>  create mode 100644 block/snapshot.c
>  create mode 100644 include/block/snapshot.h

> +++ b/block/snapshot.c
> @@ -0,0 +1,37 @@
> +/*
> + * Snapshot related functions.
> + *
> + * Copyright IBM, Corp. 2013

Technically, since you are moving code from savevm.c, you should also
preserve the copyright on that moved code:

 * Copyright (c) 2003-2008 Fabrice Bellard

> + *
> + * Authors:
> + *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.

Furthermore, the code you are moving was under BSD license, so by moving
the code, you have changed its license to something more restrictive.
Personally, I like LGPL better than BSD, but as I'm not the copyright
holder of the original code, and neither are you, I'm not sure that
either of us is qualified to make that change.  Therefore, I'm unwilling
to add my Reviewed-by, even though the code motion itself is correct,
without a maintainer chiming in on whether your licensing is appropriate
or needs an adjustment.
Wayne Xia March 12, 2013, 5:01 a.m. UTC | #2
于 2013-3-12 1:49, Eric Blake 写道:
> On 03/11/2013 05:23 AM, Wenchao Xia wrote:
>>    This patch adds block/snapshot.c and then moves the function
>> there. It also fixes small code style errors reported by check script.
>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   block/Makefile.objs      |    1 +
>>   block/snapshot.c         |   37 +++++++++++++++++++++++++++++++++++++
>>   include/block/snapshot.h |   26 ++++++++++++++++++++++++++
>>   savevm.c                 |   23 +----------------------
>>   4 files changed, 65 insertions(+), 22 deletions(-)
>>   create mode 100644 block/snapshot.c
>>   create mode 100644 include/block/snapshot.h
>
>> +++ b/block/snapshot.c
>> @@ -0,0 +1,37 @@
>> +/*
>> + * Snapshot related functions.
>> + *
>> + * Copyright IBM, Corp. 2013
>
> Technically, since you are moving code from savevm.c, you should also
> preserve the copyright on that moved code:
>
>   * Copyright (c) 2003-2008 Fabrice Bellard
>
>> + *
>> + * Authors:
>> + *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
>
> Furthermore, the code you are moving was under BSD license, so by moving
> the code, you have changed its license to something more restrictive.
> Personally, I like LGPL better than BSD, but as I'm not the copyright
> holder of the original code, and neither are you, I'm not sure that
> either of us is qualified to make that change.  Therefore, I'm unwilling
> to add my Reviewed-by, even though the code motion itself is correct,
> without a maintainer chiming in on whether your licensing is appropriate
> or needs an adjustment.
>
   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
know how to contact Fabrice Bellard to ask for a change?
Eric Blake March 12, 2013, 4:15 p.m. UTC | #3
On 03/11/2013 11:01 PM, Wenchao Xia wrote:
> 于 2013-3-12 1:49, Eric Blake 写道:
>> On 03/11/2013 05:23 AM, Wenchao Xia wrote:
>>>    This patch adds block/snapshot.c and then moves the function
>>> there. It also fixes small code style errors reported by check script.
>>>

>>> + * This work is licensed under the terms of the GNU LGPL, version 2
>>> or later.
>>
>> Furthermore, the code you are moving was under BSD license, so by moving
>> the code, you have changed its license to something more restrictive.
>> Personally, I like LGPL better than BSD, but as I'm not the copyright
>> holder of the original code, and neither are you, I'm not sure that
>> either of us is qualified to make that change.  Therefore, I'm unwilling
>> to add my Reviewed-by, even though the code motion itself is correct,
>> without a maintainer chiming in on whether your licensing is appropriate
>> or needs an adjustment.
>>
>   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
> know how to contact Fabrice Bellard to ask for a change?

As far as I can tell, there is nothing wrong with leaving the file as
BSD licensed instead of trying to insist that it be LGPL.  The block
layer will still be [L]GPL because of other files linked together, but
there is nothing inherently wrong with linking a BSD file into an [L]GPL
product.  In other words, if you are okay with keeping the existing
looser BSD license on this file only, it still won't change the license
of the overall block layer, and it would save you the hassle of tracking
down earlier authors to ask for a relicense.
Eric Blake March 12, 2013, 4:22 p.m. UTC | #4
On 03/12/2013 10:15 AM, Eric Blake wrote:
> As far as I can tell, there is nothing wrong with leaving the file as
> BSD licensed instead of trying to insist that it be LGPL.  The block
> layer will still be [L]GPL because of other files linked together, but
> there is nothing inherently wrong with linking a BSD file into an [L]GPL
> product.  In other words, if you are okay with keeping the existing
> looser BSD license on this file only, it still won't change the license
> of the overall block layer, and it would save you the hassle of tracking
> down earlier authors to ask for a relicense.

Another alternative is to have two licenses covering appropriate
portions of the file.  For example, aio-win32.c has two licenses: a
GPL2-only license for older history, and a GPLv2+ license for all new
changes.  In your case, you might be able to write a license that states
that contents of code copied from other files is BSD, but all new
contributions are LGPLv2+.

But again, this is something where I suggest you get an official answer
from a maintainer, and not just opinions from a random reviewer,
regarding what approach you should take to licensing your code motion.
Wayne Xia March 13, 2013, 1:57 a.m. UTC | #5
于 2013-3-13 0:22, Eric Blake 写道:
> On 03/12/2013 10:15 AM, Eric Blake wrote:
>> As far as I can tell, there is nothing wrong with leaving the file as
>> BSD licensed instead of trying to insist that it be LGPL.  The block
>> layer will still be [L]GPL because of other files linked together, but
>> there is nothing inherently wrong with linking a BSD file into an [L]GPL
>> product.  In other words, if you are okay with keeping the existing
>> looser BSD license on this file only, it still won't change the license
>> of the overall block layer, and it would save you the hassle of tracking
>> down earlier authors to ask for a relicense.
>
> Another alternative is to have two licenses covering appropriate
> portions of the file.  For example, aio-win32.c has two licenses: a
> GPL2-only license for older history, and a GPLv2+ license for all new
> changes.  In your case, you might be able to write a license that states
> that contents of code copied from other files is BSD, but all new
> contributions are LGPLv2+.
>
> But again, this is something where I suggest you get an official answer
> from a maintainer, and not just opinions from a random reviewer,
> regarding what approach you should take to licensing your code motion.
>

   Thanks for your comments, I am ignorant about licenses.
Dual license seems good to me. Paolo, can I have your opinion on
this?
Kevin Wolf March 13, 2013, 12:41 p.m. UTC | #6
Am 12.03.2013 um 06:01 hat Wenchao Xia geschrieben:
> 于 2013-3-12 1:49, Eric Blake 写道:
> >On 03/11/2013 05:23 AM, Wenchao Xia wrote:
> >>   This patch adds block/snapshot.c and then moves the function
> >>there. It also fixes small code style errors reported by check script.
> >>
> >>Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> >>---
> >>  block/Makefile.objs      |    1 +
> >>  block/snapshot.c         |   37 +++++++++++++++++++++++++++++++++++++
> >>  include/block/snapshot.h |   26 ++++++++++++++++++++++++++
> >>  savevm.c                 |   23 +----------------------
> >>  4 files changed, 65 insertions(+), 22 deletions(-)
> >>  create mode 100644 block/snapshot.c
> >>  create mode 100644 include/block/snapshot.h
> >
> >>+++ b/block/snapshot.c
> >>@@ -0,0 +1,37 @@
> >>+/*
> >>+ * Snapshot related functions.
> >>+ *
> >>+ * Copyright IBM, Corp. 2013
> >
> >Technically, since you are moving code from savevm.c, you should also
> >preserve the copyright on that moved code:
> >
> >  * Copyright (c) 2003-2008 Fabrice Bellard
> >
> >>+ *
> >>+ * Authors:
> >>+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
> >>+ *
> >>+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> >
> >Furthermore, the code you are moving was under BSD license, so by moving
> >the code, you have changed its license to something more restrictive.
> >Personally, I like LGPL better than BSD, but as I'm not the copyright
> >holder of the original code, and neither are you, I'm not sure that
> >either of us is qualified to make that change.  Therefore, I'm unwilling
> >to add my Reviewed-by, even though the code motion itself is correct,
> >without a maintainer chiming in on whether your licensing is appropriate
> >or needs an adjustment.
> >
>   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
> know how to contact Fabrice Bellard to ask for a change?

Fabrice is not the only copyright owner of this file.

Just copy the license as it is, changing licenses is always a nasty
thing and as I'm not a lawyer I prefer to stay on the safe side. The MIT
license works well enough, there's no real reason to change it.

Kevin
Markus Armbruster March 13, 2013, 6:08 p.m. UTC | #7
Eric Blake <eblake@redhat.com> writes:

> On 03/11/2013 05:23 AM, Wenchao Xia wrote:
>>   This patch adds block/snapshot.c and then moves the function
>> there. It also fixes small code style errors reported by check script.
>> 
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>  block/Makefile.objs      |    1 +
>>  block/snapshot.c         |   37 +++++++++++++++++++++++++++++++++++++
>>  include/block/snapshot.h |   26 ++++++++++++++++++++++++++
>>  savevm.c                 |   23 +----------------------
>>  4 files changed, 65 insertions(+), 22 deletions(-)
>>  create mode 100644 block/snapshot.c
>>  create mode 100644 include/block/snapshot.h
>
>> +++ b/block/snapshot.c
>> @@ -0,0 +1,37 @@
>> +/*
>> + * Snapshot related functions.
>> + *
>> + * Copyright IBM, Corp. 2013
>
> Technically, since you are moving code from savevm.c, you should also
> preserve the copyright on that moved code:
>
>  * Copyright (c) 2003-2008 Fabrice Bellard
>
>> + *
>> + * Authors:
>> + *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
>
> Furthermore, the code you are moving was under BSD license, so by moving
> the code, you have changed its license to something more restrictive.
> Personally, I like LGPL better than BSD, but as I'm not the copyright
> holder of the original code, and neither are you, I'm not sure that
> either of us is qualified to make that change.  Therefore, I'm unwilling
> to add my Reviewed-by, even though the code motion itself is correct,
> without a maintainer chiming in on whether your licensing is appropriate
> or needs an adjustment.

Code motion from a single file to a new file is the simplest case.  You
can't go wrong by preserving the license notice exactly then.

Things get a bit messy when you move code to an existing file that
already has a different license notice.  Whether that's even possible
depends on the licenses.

An important special case is adding copyrightable GPL'ed modifications
to a permissively-licensed file.  This need not be just code motion, it
could also happen when you start with a bit of code moved out of a
permissively- licensed file, then add copyrightable code of your own,
which you want protected by the GPL.

For how to do that properly, check out the Software Freedom Law Center's
white paper "Maintaining Permissive-Licensed Files in a GPL-Licensed
Project: Guidelines for Developers"[*] section 2.2 "Adding GPL’d
modifications to permissive-licensed files".

An in-tree example is hw/hd-geometry.c, which I rewrote substantially
after moving it out of block.c,

[*] https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
Markus Armbruster March 13, 2013, 6:19 p.m. UTC | #8
Kevin Wolf <kwolf@redhat.com> writes:

> Am 12.03.2013 um 06:01 hat Wenchao Xia geschrieben:
>>   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
>> know how to contact Fabrice Bellard to ask for a change?
>
> Fabrice is not the only copyright owner of this file.
>
> Just copy the license as it is, changing licenses is always a nasty
> thing and as I'm not a lawyer I prefer to stay on the safe side. The MIT
> license works well enough, there's no real reason to change it.

*Relicensing* a file is indeed "nasty" in the sense that it's a huge
hassle: you have to track down all copyright holders and get their
permission.

But this isn't relicensing.  This is exercising your *right* to
incorporate permissively-licensed stuff into work covered by a
compatible, stronger license.  That right was irrevocably granted to you
by the copyright holders.  You don't have to ask anyone to exercise it.

Of course, the stronger license still has to be compatible with GPLv2,
so we can accept the result into QEMU.

If a subsystem has additional requirements on licenses, its maintainers
will explain them to you.  For what it's worth, substantial parts of the
block layer are already GPLv2+.

You don't *have* to switch to a stronger license, of course.  It's your
choice.  Myself, I prefer to protect any substantial work I do with a
strong copyleft license such as GPLv2+.
Eric Blake March 13, 2013, 8:28 p.m. UTC | #9
On 03/13/2013 12:19 PM, Markus Armbruster wrote:

> But this isn't relicensing.  This is exercising your *right* to
> incorporate permissively-licensed stuff into work covered by a
> compatible, stronger license.  That right was irrevocably granted to you
> by the copyright holders.  You don't have to ask anyone to exercise it.

Cool - I like that explanation.  In that case, my concern has been
answered, and you are free to add:

Reviewed-by: Eric Blake <eblake@redhat.com>
Kevin Wolf March 14, 2013, 9:01 a.m. UTC | #10
Am 13.03.2013 um 19:19 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> 
> > Am 12.03.2013 um 06:01 hat Wenchao Xia geschrieben:
> >>   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
> >> know how to contact Fabrice Bellard to ask for a change?
> >
> > Fabrice is not the only copyright owner of this file.
> >
> > Just copy the license as it is, changing licenses is always a nasty
> > thing and as I'm not a lawyer I prefer to stay on the safe side. The MIT
> > license works well enough, there's no real reason to change it.
> 
> *Relicensing* a file is indeed "nasty" in the sense that it's a huge
> hassle: you have to track down all copyright holders and get their
> permission.
> 
> But this isn't relicensing.  This is exercising your *right* to
> incorporate permissively-licensed stuff into work covered by a
> compatible, stronger license.  That right was irrevocably granted to you
> by the copyright holders.  You don't have to ask anyone to exercise it.

But you have to do it right. This specific patch would introduce a
copyright violation. It's really not that hard to conform to the terms
of the MIT license, but that doesn't mean that you can ignore it. There
is exactly one requirement and it reads like this:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

(I'm still waiting for a patch to blockdev.c, for which you did it
wrong, by the way)

> Of course, the stronger license still has to be compatible with GPLv2,
> so we can accept the result into QEMU.
> 
> If a subsystem has additional requirements on licenses, its maintainers
> will explain them to you.  For what it's worth, substantial parts of the
> block layer are already GPLv2+.

What parts exactly? As long as there are plans for a libqblock and as
long as it doesn't seem completely impossible to have it under LGPL, I
will ask to use either MIT or LGPL for block layer code (this doesn't
apply to qemu-only code that isn't used in the tools - in this sense,
things like blockdev.c are not part of the block layer)

> You don't *have* to switch to a stronger license, of course.  It's your
> choice.  Myself, I prefer to protect any substantial work I do with a
> strong copyleft license such as GPLv2+.

And it's my choice if I accept a patch that does nothing except moving
code and switching to a stronger license. It feels wrong to do this,
even though it may be legal. If you want to change the license for
whatever reason, you should at least add substantial code of your own to
justify this.

Kevin
Markus Armbruster March 14, 2013, 12:10 p.m. UTC | #11
Kevin Wolf <kwolf@redhat.com> writes:

> Am 13.03.2013 um 19:19 hat Markus Armbruster geschrieben:
>> Kevin Wolf <kwolf@redhat.com> writes:
>> 
>> > Am 12.03.2013 um 06:01 hat Wenchao Xia geschrieben:
>> >>   Oops, Since it belongs to block layer I hope it can be LGPL2. Do you
>> >> know how to contact Fabrice Bellard to ask for a change?
>> >
>> > Fabrice is not the only copyright owner of this file.
>> >
>> > Just copy the license as it is, changing licenses is always a nasty
>> > thing and as I'm not a lawyer I prefer to stay on the safe side. The MIT
>> > license works well enough, there's no real reason to change it.
>> 
>> *Relicensing* a file is indeed "nasty" in the sense that it's a huge
>> hassle: you have to track down all copyright holders and get their
>> permission.
>> 
>> But this isn't relicensing.  This is exercising your *right* to
>> incorporate permissively-licensed stuff into work covered by a
>> compatible, stronger license.  That right was irrevocably granted to you
>> by the copyright holders.  You don't have to ask anyone to exercise it.
>
> But you have to do it right. This specific patch would introduce a
> copyright violation. It's really not that hard to conform to the terms
> of the MIT license, but that doesn't mean that you can ignore it. There
> is exactly one requirement and it reads like this:
>
>   The above copyright notice and this permission notice shall be
>   included in all copies or substantial portions of the Software.

That's why I pointed to resources and examples on how to do it properly.

> (I'm still waiting for a patch to blockdev.c, for which you did it
> wrong, by the way)

Oops, that one fell through the cracks.  Patch coming.

>> Of course, the stronger license still has to be compatible with GPLv2,
>> so we can accept the result into QEMU.
>> 
>> If a subsystem has additional requirements on licenses, its maintainers
>> will explain them to you.  For what it's worth, substantial parts of the
>> block layer are already GPLv2+.
>
> What parts exactly? As long as there are plans for a libqblock and as
> long as it doesn't seem completely impossible to have it under LGPL, I
> will ask to use either MIT or LGPL for block layer code (this doesn't
> apply to qemu-only code that isn't used in the tools - in this sense,
> things like blockdev.c are not part of the block layer)

$ git-grep -lw GPL block block*
block-migration.c
block/blkverify.c
block/gluster.c
block/linux-aio.c
block/raw-aio.h
block/rbd.c
block/sheepdog.c
blockdev-nbd.c
blockdev.c

>> You don't *have* to switch to a stronger license, of course.  It's your
>> choice.  Myself, I prefer to protect any substantial work I do with a
>> strong copyleft license such as GPLv2+.
>
> And it's my choice if I accept a patch that does nothing except moving
> code and switching to a stronger license. It feels wrong to do this,
> even though it may be legal. If you want to change the license for
> whatever reason, you should at least add substantial code of your own to
> justify this.

I wouldn't submit such a patch.  Not everything that's legal is proper.
Kevin Wolf March 14, 2013, 12:53 p.m. UTC | #12
Am 14.03.2013 um 13:10 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> > But you have to do it right. This specific patch would introduce a
> > copyright violation. It's really not that hard to conform to the terms
> > of the MIT license, but that doesn't mean that you can ignore it. There
> > is exactly one requirement and it reads like this:
> >
> >   The above copyright notice and this permission notice shall be
> >   included in all copies or substantial portions of the Software.
> 
> That's why I pointed to resources and examples on how to do it properly.
> 
> > (I'm still waiting for a patch to blockdev.c, for which you did it
> > wrong, by the way)
> 
> Oops, that one fell through the cracks.  Patch coming.

Thanks.

> >> Of course, the stronger license still has to be compatible with GPLv2,
> >> so we can accept the result into QEMU.
> >> 
> >> If a subsystem has additional requirements on licenses, its maintainers
> >> will explain them to you.  For what it's worth, substantial parts of the
> >> block layer are already GPLv2+.
> >
> > What parts exactly? As long as there are plans for a libqblock and as
> > long as it doesn't seem completely impossible to have it under LGPL, I
> > will ask to use either MIT or LGPL for block layer code (this doesn't
> > apply to qemu-only code that isn't used in the tools - in this sense,
> > things like blockdev.c are not part of the block layer)
> 
> $ git-grep -lw GPL block block*
> block-migration.c
> block/blkverify.c
> block/gluster.c
> block/linux-aio.c
> block/raw-aio.h
> block/rbd.c
> block/sheepdog.c
> blockdev-nbd.c
> blockdev.c

Luckily, none of these are really critical for a libqblock library, even
though they would be nice to have.

If we can't license such a library as LGPL, we would lose the most
important potential user, which is libvirt. In which case I probably
wouldn't want to bother with providing a library at all.

Kevin
Wayne Xia March 15, 2013, 6:23 a.m. UTC | #13
于 2013-3-14 20:53, Kevin Wolf 写道:
> Am 14.03.2013 um 13:10 hat Markus Armbruster geschrieben:
>> Kevin Wolf <kwolf@redhat.com> writes:
>>> But you have to do it right. This specific patch would introduce a
>>> copyright violation. It's really not that hard to conform to the terms
>>> of the MIT license, but that doesn't mean that you can ignore it. There
>>> is exactly one requirement and it reads like this:
>>>
>>>    The above copyright notice and this permission notice shall be
>>>    included in all copies or substantial portions of the Software.
>>
>> That's why I pointed to resources and examples on how to do it properly.
>>
>>> (I'm still waiting for a patch to blockdev.c, for which you did it
>>> wrong, by the way)
>>
>> Oops, that one fell through the cracks.  Patch coming.
>
> Thanks.
>
>>>> Of course, the stronger license still has to be compatible with GPLv2,
>>>> so we can accept the result into QEMU.
>>>>
>>>> If a subsystem has additional requirements on licenses, its maintainers
>>>> will explain them to you.  For what it's worth, substantial parts of the
>>>> block layer are already GPLv2+.
>>>
>>> What parts exactly? As long as there are plans for a libqblock and as
>>> long as it doesn't seem completely impossible to have it under LGPL, I
>>> will ask to use either MIT or LGPL for block layer code (this doesn't
>>> apply to qemu-only code that isn't used in the tools - in this sense,
>>> things like blockdev.c are not part of the block layer)
>>
>> $ git-grep -lw GPL block block*
>> block-migration.c
>> block/blkverify.c
>> block/gluster.c
>> block/linux-aio.c
>> block/raw-aio.h
>> block/rbd.c
>> block/sheepdog.c
>> blockdev-nbd.c
>> blockdev.c
>
> Luckily, none of these are really critical for a libqblock library, even
> though they would be nice to have.
>
> If we can't license such a library as LGPL, we would lose the most
> important potential user, which is libvirt. In which case I probably
> wouldn't want to bother with providing a library at all.
>
> Kevin
>
   As the discuss, I feel a direct copy of the license is the
easiest way, the original one is a good enough MIT license, if
my understanding is correct.
   One more question: should the date be changed to 2003-2013 in
new file?

/*
  * QEMU System Emulator
  *
  * Copyright (c) 2003-2008 Fabrice Bellard
.....
Kevin Wolf March 15, 2013, 8 a.m. UTC | #14
Am 15.03.2013 um 07:23 hat Wenchao Xia geschrieben:
> 于 2013-3-14 20:53, Kevin Wolf 写道:
> >Am 14.03.2013 um 13:10 hat Markus Armbruster geschrieben:
> >>Kevin Wolf <kwolf@redhat.com> writes:
> >>>But you have to do it right. This specific patch would introduce a
> >>>copyright violation. It's really not that hard to conform to the terms
> >>>of the MIT license, but that doesn't mean that you can ignore it. There
> >>>is exactly one requirement and it reads like this:
> >>>
> >>>   The above copyright notice and this permission notice shall be
> >>>   included in all copies or substantial portions of the Software.
> >>
> >>That's why I pointed to resources and examples on how to do it properly.
> >>
> >>>(I'm still waiting for a patch to blockdev.c, for which you did it
> >>>wrong, by the way)
> >>
> >>Oops, that one fell through the cracks.  Patch coming.
> >
> >Thanks.
> >
> >>>>Of course, the stronger license still has to be compatible with GPLv2,
> >>>>so we can accept the result into QEMU.
> >>>>
> >>>>If a subsystem has additional requirements on licenses, its maintainers
> >>>>will explain them to you.  For what it's worth, substantial parts of the
> >>>>block layer are already GPLv2+.
> >>>
> >>>What parts exactly? As long as there are plans for a libqblock and as
> >>>long as it doesn't seem completely impossible to have it under LGPL, I
> >>>will ask to use either MIT or LGPL for block layer code (this doesn't
> >>>apply to qemu-only code that isn't used in the tools - in this sense,
> >>>things like blockdev.c are not part of the block layer)
> >>
> >>$ git-grep -lw GPL block block*
> >>block-migration.c
> >>block/blkverify.c
> >>block/gluster.c
> >>block/linux-aio.c
> >>block/raw-aio.h
> >>block/rbd.c
> >>block/sheepdog.c
> >>blockdev-nbd.c
> >>blockdev.c
> >
> >Luckily, none of these are really critical for a libqblock library, even
> >though they would be nice to have.
> >
> >If we can't license such a library as LGPL, we would lose the most
> >important potential user, which is libvirt. In which case I probably
> >wouldn't want to bother with providing a library at all.
> >
> >Kevin
> >
>   As the discuss, I feel a direct copy of the license is the
> easiest way, the original one is a good enough MIT license, if
> my understanding is correct.
>   One more question: should the date be changed to 2003-2013 in
> new file?
> 
> /*
>  * QEMU System Emulator
>  *
>  * Copyright (c) 2003-2008 Fabrice Bellard
> .....

Probably not that important, but I would leave it as it is.

Kevin
diff mbox

Patch

diff --git a/block/Makefile.objs b/block/Makefile.objs
index c067f38..60a4cd2 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -3,6 +3,7 @@  block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-y += parallels.o blkdebug.o blkverify.o
+block-obj-y += snapshot.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
 block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
diff --git a/block/snapshot.c b/block/snapshot.c
new file mode 100644
index 0000000..8de73b4
--- /dev/null
+++ b/block/snapshot.c
@@ -0,0 +1,37 @@ 
+/*
+ * Snapshot related functions.
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#include "block/snapshot.h"
+
+int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
+                       const char *name)
+{
+    QEMUSnapshotInfo *sn_tab, *sn;
+    int nb_sns, i, ret;
+
+    ret = -ENOENT;
+    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
+    if (nb_sns < 0) {
+        return ret;
+    }
+    for (i = 0; i < nb_sns; i++) {
+        sn = &sn_tab[i];
+        if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) {
+            *sn_info = *sn;
+            ret = 0;
+            break;
+        }
+    }
+    g_free(sn_tab);
+    return ret;
+}
diff --git a/include/block/snapshot.h b/include/block/snapshot.h
new file mode 100644
index 0000000..86891d1
--- /dev/null
+++ b/include/block/snapshot.h
@@ -0,0 +1,26 @@ 
+/*
+ * Snapshot related functions.
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#ifndef SNAPSHOT_H
+#define SNAPSHOT_H
+
+#include "qemu-common.h"
+/*
+ * block.h is needed for QEMUSnapshotInfo, it can be removed when define is
+ * moved here.
+ */
+#include "block.h"
+
+int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
+                       const char *name);
+#endif
diff --git a/savevm.c b/savevm.c
index a8a53ef..95f19ca 100644
--- a/savevm.c
+++ b/savevm.c
@@ -39,6 +39,7 @@ 
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qemu/bitops.h"
+#include "block/snapshot.h"
 
 #define SELF_ANNOUNCE_ROUNDS 5
 
@@ -2060,28 +2061,6 @@  out:
     return ret;
 }
 
-static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
-                              const char *name)
-{
-    QEMUSnapshotInfo *sn_tab, *sn;
-    int nb_sns, i, ret;
-
-    ret = -ENOENT;
-    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
-    if (nb_sns < 0)
-        return ret;
-    for(i = 0; i < nb_sns; i++) {
-        sn = &sn_tab[i];
-        if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) {
-            *sn_info = *sn;
-            ret = 0;
-            break;
-        }
-    }
-    g_free(sn_tab);
-    return ret;
-}
-
 /*
  * Deletes snapshots of a given name in all opened images.
  */