I've found that the Jenkins server needs to be restarted after installing the libvirt dependencies. The "Test Connection" button is the most telling here. If the dependencies are not available then an error message is returned:

However, clicking the "Test Connection" button again then triggers an error along with the "java.lang.NoClassDefFoundError: Could not initialize class org.libvirt.Library" error message in the logs:

This error will persist, even if the dependencies are installed, until the Jenkins server is restarted.
Expected behavior is for the plugin to be able to fail gracefully if it cannot load its dependencies. Ideally the plugin would be able to re-try loading its dependencies, but informing the user that a restart will be required after installing the dependencies would also suffice.
Last tested on Ubuntu 22.04, Jenkins 2.426.1, Libvirt Agents plugin 262.v98a_c85b_98c0a_.
Did you install the libvirt library on the Jenkins host system? (https://plugins.jenkins.io/libvirt-slave/#plugin-content-requirements)