Message ID | 20250217223402.167514-1-olekstysh@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [V3,for-4.20] xen/memory: Make resource_max_frames() to return 0 on unknown type | expand |
On 17/02/2025 10:34 pm, Oleksandr Tyshchenko wrote: > diff --git a/tools/tests/resource/test-resource.c b/tools/tests/resource/test-resource.c > index 1b10be16a6..521c1fc51a 100644 > --- a/tools/tests/resource/test-resource.c > +++ b/tools/tests/resource/test-resource.c > @@ -123,6 +123,16 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames, > fail(" Fail: Managed to map gnttab v2 status frames in v1 mode\n"); > xenforeignmemory_unmap_resource(fh, res); > } > + > + /* > + * If this check starts failing, you've find the right place to test your s/find/found/ Can fix on commit, if Oleksii is happy for this to go into 4.20. Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
On 2/17/25 11:41 PM, Andrew Cooper wrote: > On 17/02/2025 10:34 pm, Oleksandr Tyshchenko wrote: >> diff --git a/tools/tests/resource/test-resource.c b/tools/tests/resource/test-resource.c >> index 1b10be16a6..521c1fc51a 100644 >> --- a/tools/tests/resource/test-resource.c >> +++ b/tools/tests/resource/test-resource.c >> @@ -123,6 +123,16 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames, >> fail(" Fail: Managed to map gnttab v2 status frames in v1 mode\n"); >> xenforeignmemory_unmap_resource(fh, res); >> } >> + >> + /* >> + * If this check starts failing, you've find the right place to test your > s/find/found/ > > Can fix on commit, if Oleksii is happy for this to go into 4.20. > > Reviewed-by: Andrew Cooper<andrew.cooper3@citrix.com> The fix looks simply and low risk so lets take it into 4.20: Release-Acked-by: Oleksii Kurochko<oleksii.kurochko@gmail.com> Thanks. ~ Oleksii
diff --git a/tools/tests/resource/test-resource.c b/tools/tests/resource/test-resource.c index 1b10be16a6..521c1fc51a 100644 --- a/tools/tests/resource/test-resource.c +++ b/tools/tests/resource/test-resource.c @@ -123,6 +123,16 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames, fail(" Fail: Managed to map gnttab v2 status frames in v1 mode\n"); xenforeignmemory_unmap_resource(fh, res); } + + /* + * If this check starts failing, you've find the right place to test your + * addition to the Acquire Resource infrastructure. + */ + rc = xenforeignmemory_resource_size(fh, domid, 3, 0, &size); + + /* Check that Xen rejected the resource type. */ + if ( !rc ) + fail(" Fail: Expected error on an invalid resource type, got success\n"); } static void test_domain_configurations(void) diff --git a/xen/common/memory.c b/xen/common/memory.c index a6f2f6d1b3..8ca4e1a842 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1157,7 +1157,7 @@ static unsigned int resource_max_frames(const struct domain *d, return d->vmtrace_size >> PAGE_SHIFT; default: - return -EOPNOTSUPP; + return 0; } } @@ -1240,6 +1240,7 @@ static int _acquire_resource( return acquire_vmtrace_buf(d, id, frame, nr_frames, mfn_list); default: + ASSERT_UNREACHABLE(); return -EOPNOTSUPP; } }