From 2aec5870276520ba31cbb38661a83bba853261df Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 28 Feb 2011 18:52:55 +0100 Subject: [PATCH 1/4] block-snapshot fixes --- common/block-snapshot | 51 ++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 20 deletions(-) mode change 100644 => 100755 common/block-snapshot diff --git a/common/block-snapshot b/common/block-snapshot old mode 100644 new mode 100755 index a08a10c..a668935 --- a/common/block-snapshot +++ b/common/block-snapshot @@ -7,7 +7,6 @@ dir=$(dirname "$0") . "$dir/block-common.sh" - get_dev() { dev=$1 @@ -26,10 +25,10 @@ get_dev() { fatal "Unable to lookup $file: dev: $devnum inode: $inode" fi - dev_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} | cut -d : -f 1) - for dev in $dev_list; do + dev_list=$(losetup -a | grep ' \[0*'${devnum}'\]:'${inode} | cut -d : -f 1) + for loopdev in $dev_list; do # found existing loop to this file - echo $dev + echo $loopdev return done @@ -141,40 +140,52 @@ case "$command" in fatal "No device node to remove" fi + if [ ! -e "$node" ]; then + fatal "Device $node does not exists" + fi + claim_lock "block" use_count=$(dmsetup info $node|grep Open|awk '{print $3}') # do not remove snapshot if snapshot origin is still present - if [ "${node/snapshot/}" != "$node" -a - -e "/dev/mapper/origin-$(echo $node|cut -d- -f2)" ]; then - ((use_count++)) + if [ "${node/snapshot/}" != "$node" -a -e "/dev/mapper/origin-$(echo $node|cut -d- -f2)" ]; then + use_count=1 fi if [ "$use_count" -gt 0 ]; then log info "Device $node still in use - not removing" + release_lock "block" exit 0 fi # get list of used (loop) devices - deps="$(dmsetup deps $node | cut -d: -f2 | sed -e 's#(7, \([0-9]+\))#/dev/loop\1#g')" + deps="$(dmsetup deps $node | cut -d: -f2 | sed -e 's#(7, \([0-9]\+\))#/dev/loop\1#g')" - # remove unused snapshots - for snap in /dev/mapper/snapshot-$(echo $node|cut -d- -f2); do - use_count=$(dmsetup info $snap|grep Open|awk '{print $3}') - if [ $use_count -eq 0 ]; then - # unused snapshot - remove it - deps="$deps $(dmsetup deps $snap | cut -d: -f2 | sed -e 's#(7, \([0-9]+\))#/dev/loop\1#g')" - dmsetup remove $snap - fi - done - - do_or_die dmsetup remove $node + # if this is origin + if [ "${node/origin/}" != "$node" ]; then + # remove unused snapshots + for snap in /dev/mapper/snapshot-$(echo $node|cut -d- -f2)-*; do + use_count=$(dmsetup info $snap|grep Open|awk '{print $3}') + if [ "$use_count" -eq 0 ]; then + # unused snapshot - remove it + deps="$deps $(dmsetup deps $snap | cut -d: -f2 | sed -e 's#(7, \([0-9]\+\))#/dev/loop\1#g')" + log debug "Removing $snap" + dmsetup remove $snap + fi + done + fi + + if [ -e $node ]; then + log debug "Removing $node" + dmsetup remove $node + fi # try to free loop devices for dev in $deps; do if [ -b "$dev" ]; then - losetup -d $dev 2> /dev/null + log debug "Removing $dev" + losetup -d $dev || true 2> /dev/null fi done From 8fa18c465886ded5014191d02e4a1fdc5962d349 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 2 Mar 2011 11:35:36 +0100 Subject: [PATCH 2/4] Add backup files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4d22dcb..228b7ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ rpm/ *.pyc +*~ From ee5542ee43bb361efdc0bcfd78df1ed92353a2aa Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 2 Mar 2011 11:55:54 +0100 Subject: [PATCH 3/4] Add BR to core-appvm.spec --- rpm_spec/core-appvm.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpm_spec/core-appvm.spec b/rpm_spec/core-appvm.spec index c9a009d..e901a12 100644 --- a/rpm_spec/core-appvm.spec +++ b/rpm_spec/core-appvm.spec @@ -34,6 +34,8 @@ URL: http://www.qubes-os.org Requires: /usr/bin/xenstore-read Requires: fedora-release = 13 Requires: /usr/bin/mimeopen +BuildRequires: gcc +BuildRequires: xen-devel Provides: qubes-core-vm %define _builddir %(pwd)/appvm From 088adcc95f40f6e23f8cdc4ea3cdc4be5fd437d9 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 2 Mar 2011 11:58:22 +0100 Subject: [PATCH 4/4] gitignore files - add build products --- .gitignore | 2 ++ appvm/.gitignore | 3 +++ common/.gitignore | 1 + 3 files changed, 6 insertions(+) create mode 100644 appvm/.gitignore create mode 100644 common/.gitignore diff --git a/.gitignore b/.gitignore index 228b7ab..e244064 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ rpm/ *.pyc +*.pyo *~ +*.o diff --git a/appvm/.gitignore b/appvm/.gitignore new file mode 100644 index 0000000..edd6d09 --- /dev/null +++ b/appvm/.gitignore @@ -0,0 +1,3 @@ +qubes_add_pendrive_script +qubes_penctl +qvm-open-in-dvm diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..03034a9 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1 @@ +meminfo-writer