Created attachment 659067 [details] Fix create linear. Description of problem: We can't create snapshots from the C/python APIs, this adds that functionality ... works for me :). Also fix the long vs. uintmax problem on get args. for create_linear. This is the fix: http://james.fedorapeople.org/patches/pylvm2-fix-size-create-linear.patch This is to add snapshot creation to the lvm2 C API: http://james.fedorapeople.org/patches/lvm2-create-snapshot-api.patch This is to add lv.snapshot() to the python API: http://james.fedorapeople.org/patches/pylvm2-create-snapshot-api.patch After both you can do: lv = vg.lvFromName(originname) lv.snapshot(snapname, snapsize)
Created attachment 659068 [details] Add snapshot C API
Created attachment 659069 [details] Add python snapshot API
Hi James, My colleague Tony actually posted some very similar patches back about a month ago, but they weren't committed -- I'm not sure why. If someone other than just Tony and I are working on this code we need to be better about this! :-( Sorry. OK about the code: * for the fix, can't we simply cast &size to unsigned long * instead of needing a new variable? Also, last added line uses spaces instead of tab, something to watch out for. * for the C api patch, looking at the two versions I think Tony's version here: https://www.redhat.com/archives/lvm-devel/2012-November/msg00023.html might be a little more complete. Would you mind reviewing his patch and posting any edits you have here, so we can commit the best of both? * For the Python patch, I think your patch is a little more straightforward than Tony's: https://www.redhat.com/archives/lvm-devel/2012-November/msg00022.html but also uses asize, so maybe we can just use a cast here too?
(In reply to comment #3) > * For the Python patch, I think your patch is a little more straightforward > than Tony's: I was trying to eliminate dupliate code that is common between creating a linear volume and creating a snapshot. I would be fine with either approach.
Good to know I got the solution pretty close to perfect then :). On the C API side, it seemed more "logical" to me that the API looks similar to lvm_vg_create_lv_linear() (and be at the same "level" etc.) ... but you guys know the code better than me, so I'll defer to you there. Having size == 0 work is a nice bonus, and it's probably worth have lv.snapshot("foo") work using size==0. Not sure why you need to set segtype and stripes (it worked without, and I'd assume they'd be inherited from the origin) ... but I could easily be missing something there :). For the python side, I was trying to do the opposite of Tony ... make sure I didn't break the create function while adding/testing the snapshot one :). Having less code is fine by me :). You can't just cast though as sizeof(long) == 4 and sizeof(uint64_t) == 8 on i386, so AFAIK the only way to workaround that is to have a second variable.
This has been applied to lvm2 -- python-lvm is EOLed so not going to add new features.