~smoser/ubuntu/xenial/cloud-utils/pkg

« back to all changes in this revision

Viewing changes to debian/patches/sync-to-trunk.patch

  • Committer: Scott Moser
  • Date: 2016-02-17 15:28:19 UTC
  • Revision ID: smoser@ubuntu.com-20160217152819-u4lc851weskue7re
* sync to trunk at revno 281
  * mount-image-callback: default to '--partition=auto' and
    better waiting for nbd partitions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Patch created with './debian/update-sync-to-main ../trunk'
2
2
------------------------------------------------------------
 
3
revno: 281
 
4
committer: Scott Moser <smoser@ubuntu.com>
 
5
branch nick: trunk
 
6
timestamp: Mon 2016-02-01 11:42:39 +0100
 
7
message:
 
8
  ubuntu-cloudimg-query: support arch input of 'powerpc' and 's390x'
 
9
    
 
10
  cloud images are now available for s390 and support powerpc there also.
 
11
------------------------------------------------------------
 
12
revno: 280
 
13
committer: Scott Moser <smoser@ubuntu.com>
 
14
branch nick: trunk
 
15
timestamp: Wed 2016-01-27 12:53:13 -0500
 
16
message:
 
17
  mount-image-callback: better waiting for devices
 
18
  
 
19
  on power8 systems we were failing to mount partitioned images.
 
20
  The reason was mostly that we were looking for nbd0p1 too quickly.
 
21
  The change here is to wait with 'sfdisk' to return success on the
 
22
  nbd device.  That should then indicate it is ready to use.
 
23
  
 
24
  We use it to determine if 'auto' (no --partition flag) should
 
25
  be 0 or 1.  We can then wait more intently for the block device
 
26
  to appear as we know whether or not nbd0p1 *should* appear.
 
27
------------------------------------------------------------
3
28
revno: 279 [merge]
4
29
committer: Scott Moser <smoser@ubuntu.com>
5
30
branch nick: trunk
6
 
timestamp: Mon 2016-01-18 21:25:27 -0500
 
31
timestamp: Tue 2016-01-19 13:07:02 -0500
7
32
message:
8
33
  sync packaging with what is in xenial and split euca2ools pieces
9
34
  
572
597
Use --include-merged or -n0 to see merged revisions.
573
598
=== modified file 'ChangeLog'
574
599
--- old/ChangeLog       2013-03-27 13:10:52 +0000
575
 
+++ new/ChangeLog       2015-11-04 20:48:16 +0000
576
 
@@ -1,3 +1,40 @@
 
600
+++ new/ChangeLog       2016-02-01 10:42:39 +0000
 
601
@@ -1,3 +1,42 @@
577
602
+0.28
578
603
+ - ubuntu-cloudimg-query: change default release to 'precise'
579
604
+ - growpart: fix some issues in error path reporting
610
635
+ - mount-image-callback: add '--mountpoint' flag to mount to an existing dir
611
636
+ - mount-image-callback: add '--overlay' to use overlayfs mounts
612
637
+ - mount-image-callback: use qemu-nbd --read-only for safer read only
 
638
+ - mount-image-callback: improved waiting for devices. part=auto now default.
 
639
+ - ubuntu-cloudimg-query: support arch input of 'powerpc' and 's390x'
613
640
+
614
641
 0.27
615
642
  - cloud-publish-image: add '--hook-img' flag to cloud-publish-image and
2224
2251
 
2225
2252
=== added file 'bin/mount-image-callback'
2226
2253
--- old/bin/mount-image-callback        1970-01-01 00:00:00 +0000
2227
 
+++ new/bin/mount-image-callback        2015-11-04 20:48:16 +0000
2228
 
@@ -0,0 +1,379 @@
 
2254
+++ new/bin/mount-image-callback        2016-01-27 17:53:13 +0000
 
2255
@@ -0,0 +1,430 @@
2229
2256
+#!/bin/bash
2230
2257
+
2231
2258
+VERBOSITY=0
2254
2281
+         --read-only           use read-only mount.
2255
2282
+    -m | --mountpoint MP       mount to directory MP rather than a temp dir
2256
2283
+         --overlay             mount via overlayfs
2257
 
+    -P | --partition PARTNUM   mount partition PARTNUM (default 1)
 
2284
+    -P | --partition PARTNUM   mount partition PARTNUM (default 'auto')
 
2285
+                               if 'auto', then mount part 1 if image is 
 
2286
+                               partitioned otherwise mount image
2258
2287
+    -p | --proc                bind mount /proc
2259
2288
+    -s | --sys                 bind mount /sys
2260
2289
+    -d | --dev                 bind mount /dev
2289
2318
+bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; exit 1; }
2290
2319
+
2291
2320
+disconnect_qemu() {
2292
 
+       local out="" nbd="$1"
 
2321
+       [ -n "$QEMU_DISCONNECT" ] || return 0
 
2322
+       local out="" nbd="$QEMU_DISCONNECT"
 
2323
+       local pid="" pfile="/sys/block/${nbd#/dev/}/pid"
 
2324
+       { read pid < "$pfile" ; } >/dev/null 2>&1
 
2325
+       [ -n "$pid" -a ! -d "/proc/$pid" ] && 
 
2326
+               error "qemu-nbd process seems to have died. was '$pid'"
2293
2327
+       out=$(qemu-nbd --disconnect "$nbd" 2>&1) &&
2294
2328
+               QEMU_DISCONNECT="" || {
2295
2329
+                       error "failed to disconnect $nbd";
2323
2357
+               debug 2 "umounts: ${UMOUNTS[*]}"
2324
2358
+               do_umounts "${UMOUNTS[@]}"
2325
2359
+       fi
2326
 
+       if [ -n "$QEMU_DISCONNECT" ]; then
2327
 
+               local out=""
2328
 
+               out=$(qemu-nbd --disconnect "$QEMU_DISCONNECT" 2>&1) || {
2329
 
+                       error "warning: failed: qemu-nbd --disconnect $QEMU_DISCONNECT"
2330
 
+                       error "$out"
2331
 
+               }
2332
 
+       fi
 
2360
+       disconnect_qemu
2333
2361
+       [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] ||
2334
2362
+               rm --one-file-system -Rf "${TEMP_D}" ||
2335
2363
+               error "removal of temp dir failed!"
2348
2376
+               _RET="$out"
2349
2377
+}
2350
2378
+
 
2379
+get_partition() {
 
2380
+       # return in _RET the 'auto' partition for a image.
 
2381
+       # return partition number for a partitioned image
 
2382
+       # return 0 for unpartitioned
 
2383
+       # return 0 if image is partitioned, 1 if not
 
2384
+       local img="$1"
 
2385
+       out=$(LANG=C sfdisk --list -uS "$img" 2>&1) || {
 
2386
+               error "failed determining if partitioned: $out";
 
2387
+               return 1;
 
2388
+       }
 
2389
+       if echo "$out" | grep -q 'Device.*Start.*End'; then
 
2390
+               _RET=1
 
2391
+       else
 
2392
+               _RET=0
 
2393
+       fi
 
2394
+}
 
2395
+
2351
2396
+mount_callback_umount() {
2352
2397
+       local img_in="$1" dev="" out="" mp="" ret="" img="" readonly=""
2353
 
+       local opts="" bmounts="" system_resolvconf=false ptnum=1
 
2398
+       local opts="" bmounts="" system_resolvconf=false ptnum=auto
2354
2399
+       local cd_mountpoint=false fmt="" mp_is_tmp=false overlay=false
2355
2400
+       local img_mp="" workd=""
2356
2401
+
2511
2556
+                       done
2512
2557
+               fi
2513
2558
+
2514
 
+               debug 1 "connected $img_in ($fmt) to $nbd. now udev-settling"
 
2559
+               local nptnum=""
 
2560
+               debug 1 "connected $img_in ($fmt) to $nbd. waiting for device."
 
2561
+               i=0
 
2562
+               while i=$(($i+1)):; do
 
2563
+                       get_partition "$nbd" && nptnum="$_RET" && break
 
2564
+                       [ $i -eq 40 ] && {
 
2565
+                               error "gave up on $nbd"
 
2566
+                               return 1
 
2567
+                       }
 
2568
+                       [ $(($i%10)) -eq 0 ] &&
 
2569
+                               debug 1 "waiting for $nbd to be ready."
 
2570
+                       sleep .1
 
2571
+               done
 
2572
+
2515
2573
+               udevadm settle >/dev/null 2>&1
2516
 
+
2517
 
+               local mdev="$nbd"
2518
 
+               if [ -b "${nbd}p${ptnum}" ]; then
 
2574
+               if [ "${ptnum}" = "auto" ]; then
 
2575
+                       if [ "$nptnum" = "0" ]; then
 
2576
+                               debug 1 "unpartitioned disk."
 
2577
+                       else
 
2578
+                               debug 1 "partitioned disk."
 
2579
+                       fi
 
2580
+                       ptnum=$nptnum
 
2581
+               fi
 
2582
+               if [ "$ptnum" -ne 0 ]; then
2519
2583
+                       mdev="${nbd}p${ptnum}"
 
2584
+               else
 
2585
+                       mdev="${nbd}"
2520
2586
+               fi
 
2587
+               i=0
 
2588
+               while :; do
 
2589
+                       [ -b "$mdev" ] && break
 
2590
+                       i=$(($i+1))
 
2591
+                       [ $i -eq 100 ] && {
 
2592
+                               error "gave up on waiting for $mdev"
 
2593
+                               return 1
 
2594
+                       }
 
2595
+                       [ $(($i%10)) -eq 0 ] &&
 
2596
+                               debug 1 "waiting for $mdev part=$ptnum to be ready."
 
2597
+                       sleep .1
 
2598
+               done
 
2599
+
2521
2600
+               if ( set -f; mount ${ro:+-o ${ro}} $opts "$mdev" "$img_mp" ) &&
2522
2601
+                       UMOUNTS[${#UMOUNTS[@]}]="$img_mp"; then
2523
2602
+                       debug 1 "mounted $mdev via qemu-nbd $nbd"
2527
2606
+                       [ -n "$pid" -a ! -d "/proc/$pid" ] ||
2528
2607
+                               error "qemu-nbd process seems to have died. was '$pid'"
2529
2608
+
2530
 
+                       qemu-nbd --disconnect "$nbd" && QEMU_DISCONNECT=""
2531
2609
+                       error "failed to mount $mdev"
2532
2610
+                       return 1
2533
2611
+               fi
2597
2675
+
2598
2676
+       
2599
2677
+       if [ -n "$QEMU_DISCONNECT" ]; then
2600
 
+               disconnect_qemu "$QEMU_DISCONNECT" && QEMU_DISCONNECT="" || return 1;
 
2678
+               disconnect_qemu || return 1;
2601
2679
+       fi
2602
2680
+       return $ret
2603
2681
+}
2608
2686
 
2609
2687
=== modified file 'bin/ubuntu-cloudimg-query'
2610
2688
--- old/bin/ubuntu-cloudimg-query       2013-02-04 16:32:56 +0000
2611
 
+++ new/bin/ubuntu-cloudimg-query       2015-03-11 18:12:55 +0000
 
2689
+++ new/bin/ubuntu-cloudimg-query       2016-02-01 10:42:39 +0000
2612
2690
@@ -5,7 +5,8 @@
2613
2691
 NAME="ubuntu-cloudimg-query"
2614
2692
 DOT_D="$HOME/.$NAME"
2658
2736
                daily) stream=${i};;
2659
2737
                server|desktop) bname=${i};;
2660
2738
-               i386|amd64|x86_64) arch=${i}; [ "${i}" = "x86_64" ] && arch="amd64";;
2661
 
+               i386|amd64|x86_64|armhf|ppc64el|arm64)
 
2739
+               i386|amd64|x86_64|armhf|ppc64el|arm64|s390x|powerpc)
2662
2740
+                       arch=${i};
2663
2741
+                       [ "${i}" = "x86_64" ] && arch="amd64";;
2664
2742
                *-*-[0-9]) region=${i};;