Skip to content

Commit

Permalink
Add 0002-Add-an-option-to-use-backup-footer-when-vhd-util-que.patch
Browse files Browse the repository at this point in the history
Signed-off-by: Ronan Abhamon <[email protected]>
  • Loading branch information
Wescoeur committed Dec 18, 2024
1 parent ecb5911 commit 723568c
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 567513e1c46d4a2b730a653f215fe49ade07e589 Mon Sep 17 00:00:00 2001
From e371dd87ad668e156309992bc83b96ad34fb4d38 Mon Sep 17 00:00:00 2001
From: Ronan Abhamon <[email protected]>
Date: Thu, 16 Mar 2023 15:55:07 +0100
Subject: [PATCH] Add an option to never resolve parent path when vhd-util
Subject: [PATCH 1/2] Add an option to never resolve parent path when vhd-util
query is called

Signed-off-by: Ronan Abhamon <[email protected]>
Expand All @@ -12,10 +12,10 @@ Signed-off-by: Ronan Abhamon <[email protected]>
3 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/include/libvhd.h b/include/libvhd.h
index b0adc92..ecf307f 100644
index 7365918..3932547 100644
--- a/include/libvhd.h
+++ b/include/libvhd.h
@@ -330,6 +330,7 @@ int vhd_initialize_header_parent_name(vhd_context_t *, const char *);
@@ -341,6 +341,7 @@ int vhd_initialize_header_parent_name(vhd_context_t *, const char *);
int vhd_write_parent_locators(vhd_context_t *, const char *);
int vhd_parent_locator_count(vhd_context_t *);
int vhd_parent_locator_get(vhd_context_t *, char **);
Expand All @@ -24,10 +24,10 @@ index b0adc92..ecf307f 100644

int vhd_parent_locator_read(vhd_context_t *, vhd_parent_locator_t *, char **);
diff --git a/vhd/lib/libvhd.c b/vhd/lib/libvhd.c
index ce189ca..0ce4a5c 100644
index 73be3ee..830e95a 100644
--- a/vhd/lib/libvhd.c
+++ b/vhd/lib/libvhd.c
@@ -1812,8 +1812,8 @@ out:
@@ -1782,8 +1782,8 @@ out:
return err;
}

Expand All @@ -38,7 +38,7 @@ index ce189ca..0ce4a5c 100644
{
int i, n, err;
char *name, *location;
@@ -1837,6 +1837,11 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent)
@@ -1807,6 +1807,11 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent)
if (_err)
continue;

Expand All @@ -50,7 +50,7 @@ index ce189ca..0ce4a5c 100644
err = vhd_find_parent(ctx, name, &location);
if (err)
VHDLOG("%s: couldn't find parent %s (%d)\n",
@@ -1852,6 +1857,18 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent)
@@ -1822,6 +1827,18 @@ vhd_parent_locator_get(vhd_context_t *ctx, char **parent)
return err;
}

Expand Down Expand Up @@ -142,6 +142,3 @@ index 9aa131e..0cd0416 100644
+ "[-h help]\n");
return err;
}
--
2.41.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
From 7c168ec7818aa74bf81ae27ddd808c227b1d2261 Mon Sep 17 00:00:00 2001
From: Ronan Abhamon <[email protected]>
Date: Wed, 18 Dec 2024 16:55:26 +0100
Subject: [PATCH 2/2] Add an option to use backup footer when vhd-util query is
called

This option already exists on td-util but it was not implemented
on vhd-util.

Signed-off-by: Ronan Abhamon <[email protected]>
---
vhd/lib/vhd-util-query.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/vhd/lib/vhd-util-query.c b/vhd/lib/vhd-util-query.c
index 0cd0416..13bd563 100644
--- a/vhd/lib/vhd-util-query.c
+++ b/vhd/lib/vhd-util-query.c
@@ -43,29 +43,29 @@
int
vhd_util_query(int argc, char **argv)
{
- char *name;
vhd_context_t vhd;
off64_t currsize;
- int ret, err, c, size, physize, parent, fields, depth, fastresize, marker, allocated, resolve_parent;
-
- name = NULL;
- size = 0;
- physize = 0;
- parent = 0;
- fields = 0;
- depth = 0;
- fastresize = 0;
- marker = 0;
- allocated = 0;
- resolve_parent = 1;
-
+ int ret, err, c;
+
+ char *name = NULL;
+ int size = 0;
+ int physize = 0;
+ int parent = 0;
+ int fields = 0;
+ int depth = 0;
+ int fastresize = 0;
+ int marker = 0;
+ int allocated = 0;
+ int resolve_parent = 1;
+ int flags = VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED;
+
if (!argc || !argv) {
err = -EINVAL;
goto usage;
}

optind = 0;
- while ((c = getopt(argc, argv, "n:vspfdSmauh")) != -1) {
+ while ((c = getopt(argc, argv, "n:vspfdSmaubh")) != -1) {
switch (c) {
case 'n':
name = optarg;
@@ -97,6 +97,9 @@ vhd_util_query(int argc, char **argv)
case 'u':
resolve_parent = 0;
break;
+ case 'b':
+ flags |= VHD_OPEN_USE_BKP_FOOTER;
+ break;
case 'h':
err = 0;
goto usage;
@@ -111,7 +114,7 @@ vhd_util_query(int argc, char **argv)
goto usage;
}

- err = vhd_open(&vhd, name, VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED);
+ err = vhd_open(&vhd, name, flags);
if (err) {
printf("error opening %s: %d\n", name, err);
return err;
@@ -218,6 +221,7 @@ usage:
"[-S print max virtual size (MB) for fast resize] "
"[-a print allocated block count] "
"[-u don't resolve parent path] "
+ "[-b don't trust the footer, use the back-up one instead] "
"[-h help]\n");
return err;
}
7 changes: 6 additions & 1 deletion SPECS/blktap.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Summary: blktap user space utilities
Name: blktap
Version: 3.54.9
Release: 1%{?xsrel}.1%{?dist}
Release: 1%{?xsrel}.2%{?dist}
License: BSD
Group: System/Hypervisor
URL: https://github.com/xapi-project/blktap
Expand Down Expand Up @@ -32,6 +32,8 @@ Provides: blktap(nbd) = 2.0
# XCP-ng patches
# Required by XOSTOR. Upstream PR: https://github.com/xapi-project/blktap/pull/378
Patch1001: 0001-Add-an-option-to-never-resolve-parent-path-when-vhd-.patch
# Required by sm (qcow2). Upstream PR: https://github.com/xapi-project/blktap/pull/417
Patch1002: 0002-Add-an-option-to-use-backup-footer-when-vhd-util-que.patch

%description
Blktap creates kernel block devices which realize I/O requests to
Expand Down Expand Up @@ -173,6 +175,9 @@ without requiring other libraries
%{_libdir}/libblockcrypto.so.*

%changelog
* Wed Dec 18 2024 Ronan Abhamon <[email protected]> - 3.54.9-1.2
- Add 0002-Add-an-option-to-use-backup-footer-when-vhd-util-que.patch

* Tue Jun 18 2024 Samuel Verschelde <[email protected]> - 3.54.9-1.1
- Sync with 3.54.9-1
- *** Upstream changelog ***
Expand Down

0 comments on commit 723568c

Please sign in to comment.